Coder Social home page Coder Social logo

Async call handling about njstrace HOT 11 CLOSED

deepalitandel avatar deepalitandel commented on July 30, 2024
Async call handling

from njstrace.

Comments (11)

ValYouW avatar ValYouW commented on July 30, 2024

Not sure I understand the question.

from njstrace.

drv1234 avatar drv1234 commented on July 30, 2024

hi,
could you please help me? It seems async is not supported.
If I change the example file to this, exception happens when I try to run.

// *** mymod.js ***
exports.run = async function(number) {
number = await first(number);
printResult(number);
}
:
:

from njstrace.

ValYouW avatar ValYouW commented on July 30, 2024

@drv1234 async/await is part of ES8, need to check if it supported by the javascript parser being used

from njstrace.

drv1234 avatar drv1234 commented on July 30, 2024

I use the latest node js. Without njstrace instrment the code runs fine.

from njstrace.

drv1234 avatar drv1234 commented on July 30, 2024

here is the printout:

njsTrace: New instance of NJSTrace created with config: { enabled: true,
files: [ '/*.js', '!/node_modules/**' ],
wrapFunctions: false,
logger: true,
inspectArgs: true }
njsTrace: Creating new Injector and hijacking Module.prototype._compile
njsTrace: Setting global.njsTraceEntry function
njsTrace: Setting global.njsTraceExit function
njsTrace: Setting global.njsOnCatchClause function
njsTrace: njsTrace done loading...
njsTrace: Instrumenting: c:\temp\mymod.js
njsTrace: ERROR: Error instrumenting file: c:\temp\mymod.js , Exception: { Error: Line 3: Unexpected token function
at throwError (c:\temp\node_modules\falafel\node_modules\esprima\esprima.js:1467:21)
at throwUnexpected (c:\temp\node_modules\falafel\node_modules\esprima\esprima.js:1521:13)
at consumeSemicolon (c:\temp\node_modules\falafel\node_modules\esprima\esprima.js:1605:13)
at parseStatement (c:\temp\node_modules\falafel\node_modules\esprima\esprima.js:2853:9)
at c:\temp\node_modules\falafel\node_modules\esprima\esprima.js:3588:38
at parseSourceElement (c:\temp\node_modules\falafel\node_modules\esprima\esprima.js:3073:20)
at parseFunctionSourceElements (c:\temp\node_modules\falafel\node_modules\esprima\esprima.js:2905:29)
at c:\temp\node_modules\falafel\node_modules\esprima\esprima.js:3588:38
at parseFunctionExpression (c:\temp\node_modules\falafel\node_modules\esprima\esprima.js:3045:16)
at c:\temp\node_modules\falafel\node_modules\esprima\esprima.js:3588:38
index: 104,
lineNumber: 3,
column: 21,
description: 'Unexpected token function' }
c:\temp\main.js:10
mymod.run(parseFloat(Math.random().toFixed(4)));
^

TypeError: mymod.run is not a function
at Object. (c:\temp\main.js:10:7)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3

from njstrace.

ValYouW avatar ValYouW commented on July 30, 2024

I know async await is suppurted in Nodejs, it is not supported by the library I am using to parse the javascript files (at lease in the way I'm currently doing it)

from njstrace.

drv1234 avatar drv1234 commented on July 30, 2024

Thanks.
Are you planning to support it in the near future?
Or shall I find other ways?

from njstrace.

ValYouW avatar ValYouW commented on July 30, 2024

It is really up to whether this library supports it, if it does it should be relatively easy to support it. I'll try to find some time to check it on the weekend

from njstrace.

drv1234 avatar drv1234 commented on July 30, 2024

Thank you in advance!
Please let me know.

from njstrace.

ValYouW avatar ValYouW commented on July 30, 2024

@drv1234 Please see if the latest version (1.0.1) works for you. Did some very basic async/await and it seems ok, not sure how it will work on a large scale project...

from njstrace.

drv1234 avatar drv1234 commented on July 30, 2024

hi,
thanks, I tried on my project and it works like a charm.

But...
The named (optional) parameters are not printed even if they are in the caller line.
I don't know is it up to you or it comes from external lib.
(unfortunately there are a lot of this kind of function in my project, because it is a test framework and it is continuously developed but older test are not modified)

To see, modify the example:

// *** main.js
:
mymod.run(parseFloat(Math.random().toFixed(4)), xx=11);

// *** mymod.js ***
exports.run = async function (number, xx=22) {

from njstrace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.