-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async/await debugging jumping #221
Comments
Can you try in Firefox and see if it results in the same behavior? Most likely, this is faulty source-map construction and not the fault of the lib itself. The compiler needs to give this lib correct information for it to work right. |
I'm running in Node... I see it in Node-Inspector, VSCode Debugger and Webstorm Debugger. I'll try to replicate in browser though. |
This issue would really benefit from a reduced test case and a link to https://sokra.github.io/source-map-visualization/ with the reduced test case's source map loaded. |
Here's an example: export class MyClass {
async foo() {
console.log('1. calling bar');
let result = await this.bar();
console.log('4. promise resolved');
console.log('5.', result);
return result;
}
async bar(){
console.log('2. returning promise');
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve('hello')
}, 1000);
});
}
}
let ob = new MyClass();
ob.foo();
console.log('3. continuing execution...') Here is the the sourcemap visualization for it: LINK |
Your link isn't working for me, but I tried myself on that test case and it looks alright in the visualizer Looking in some more... |
The test case won't compile for me with |
That's pretty much the same sourcemap output I'm getting. Try debugging and setting a breakpoint on the line with the await call. What I would expect instead is to either
|
Setting a breakpoint on which line? |
|
This is largely working as I expect in Firefox's debugger. Nor is this an issue with the
That's because you are exiting that frame when you yield (or await). Any other JS could run in between and it might throw exceptions or hit other breakpoints, etc.
The debugger could choose to set a temporary breakpoint for when control returns to the generator/async function, so you can "step over" asynchronous things. I've filed https://bugzilla.mozilla.org/show_bug.cgi?id=1238745 for that behavior in Firefox. But again, this is not a bug with the |
@fitzgen Thanks for the feedback! Wasn't sure where it should land, i side with the temporary breakpoint! |
I understand that await releases the frame, so is await in .net releases thread. But it doesn't jump the hell away from it. As far as control flow of function under debugger goes it's linear, it really is NOT on the bottom skipping previous statements. The way it currently looks. |
hey, any update on this? |
I'm having spotty debugging experiences when I try to debug code with async/await using
transform-async-to-generator
babel plugin ( although I've tried almost every other combination ).Essentially code with a await will skip to the end of the method and then go into the compiled code. video
If you take a look at the generated code for that function:
its no wonder regarding the results but source maps should handle this, right?
I've tried this with a variety of setups ( require hook / babel-node / babel cli / gulp babel ) and get same issue. I'm using: Node 5.4.0 and Babel 6.4.0
I've created a demo project on github. I've also posted the question on the babel thread.
The text was updated successfully, but these errors were encountered: