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
Cannot step over a fiber yield when debugging server with Meteor 1.6 #9275
Comments
Once you're paused on that |
In my own experience, the old |
Yes, that's a potential workaround. It does mean that when stepping, I have to remember which functions might yield, and if I forget one and the server runs past the code I care about, I have to start the test over. Maybe this won't be so bad once I get used to it. What do you think about referencing this issue from the item in History.md about the changes to debugging? It took me an hour and a half to track down this problem and I would want to try to save other users from wasting time, although maybe the fact that the problem wasn't found earlier in the testing of Meteor 1.6 suggests that users rarely try to step over a Mongo collection write on the server; I expected that would be common during debugging. |
I think this is a very large limitation. It means that you can't really step through a function (w/o setting additional breakpoints anyways) and that many commands run in the debug console won't work properly. Is there a way of intercepting commands sent from the Chrome debugger to the Node server? |
After multiple days of debugging, I have tracked this problem down to a pair of methods that were never fully implemented in V8: char* Debug::ArchiveDebug(char* storage) {
// Simply reset state. Don't archive anything.
ThreadInit();
return storage + ArchiveSpacePerThread();
}
char* Debug::RestoreDebug(char* storage) {
// Simply reset state. Don't restore anything.
ThreadInit();
return storage + ArchiveSpacePerThread();
} These methods are important because they are called whenever a new thread takes control of the V8 The good news is that the I was deeply worried for a few days that we would have to find an alternative to fibers, or encourage the community to stop using them. As long as fibers behave like threads as far as V8 is concerned, and V8 continues to tolerate multiple threads (which it will), I'm confident the idea of fibers/coroutines will remain viable. Thanks again to @laverdet for keeping https://github.com/laverdet/node-fibers up-to-date across so many major Node.js versions. My initial post to the v8-users list: https://groups.google.com/forum/#!topic/v8-users/_Qf2rwljRk8 Until that PR is merged into V8 (days, weeks?), and Node.js updates to that new version of V8 (months?), and Meteor updates to that version of Node.js (following the LTS schedule), we will have to back-port this patch manually, and ship Meteor with a patched version of Node.js. That's not ideal, but it means we can fix this problem in Meteor 1.6.1, rather than waiting… years? |
@benjamn You are amazing :) |
Since this has been diagnosed as an upstream-upstream bug, and fixing it in Meteor 1.6.1 would require building a custom version of Node and V8, I think it may be safer to wait until Meteor 1.6.2, just because the jump from using an official Node release to one we compiled ourselves is non-trivial, and I'd like to get Meteor 1.6.1 out sooner rather than later. (cc @abernix @hwillson) |
I completely agree @benjamn - the 1.6.1 commit list is getting pretty big and there are some great things ready to go. Holding off on including a custom Node release until 1.6.2 sounds good to me. |
I think, I am experiencing similar behaviour with the latest webstorm. |
@benjamn It seems that https://chromium-review.googlesource.com/c/v8/v8/+/833260 never got merged; any chance you could take another look and try to get it merged? |
Awesome, thanks! |
Ok, I have written a much better test for my V8 changes, which revealed some flaws in my previous implementation of |
@benjamn woooooooooooooooooooooooooooooooo thanks! The Chrome team recently released ndb (https://github.com/GoogleChromeLabs/ndb). Has some pretty neat features. Might make the debugging experience even better. Hmm... have you ever tried using the devtools for working with the build tool? |
@veered I always use |
My CR was just merged into V8 |
That's awesome! The debug tools will now be way way more useful |
My change has now been merged into the It's also slated to be included in Node 10.10.0: nodejs/node#22716 I'm still hoping it can be included in Node 8.12.0, pending this PR: nodejs/node#22714 |
Chrome DevTools team recently launched support for NDB: https://developers.google.com/web/updates/2018/08/devtools#ndb Any chance to use it with Meteor? Tried to launch Meteor via Thanks. Related https://forums.meteor.com/t/meteor-and-new-ndb-for-debugging/44818 |
The @nicooprat I would imagine you can still run |
Regarding the ndb support: I can't seem to figure out a way to make ndb run. It does look like you need to use ndb instead of the normal node call. Any advice on making it run would be appreciated. |
Release blog post: https://nodejs.org/en/blog/release/v8.13.0/ This release includes my PR to improve multi-threaded debugging, which should finally fix #9275: nodejs/node#22714
I'm thrilled to report this bug is finally fixed after running I can't think of any other bugs I've encountered in my career that consumed this much time (though maybe I've blocked them out), but I guess that's what happens when you're dealing with subtle C++ multi-threading bugs in an upstream-upstream project. |
In order to reflect what's been fixed in the Meteor 1.8.1 milestone so far, I'm going to close this issue now, though of course the fix is not in any official Meteor release yet. |
When I'm debugging the server of a Meteor 1.6 application using the Node.js built-in debugger, when I try to step over a function call that yields the current fiber, the server goes on running and does not stop on the next line of code. Using Meteor 1.5.2.2 and node-inspector, the server properly stops on the next line. Maybe it's possible to use node-inspector with Meteor 1.6, but this doesn't look promising. So this looks like a significant loss of debugging functionality for server code that (for example) writes to Mongo collections. This may be enough grounds for me to hold off on upgrading to Meteor 1.6.
I imagine the underlying incompatibility between fibers and the Node.js built-in debugger is nothing Meteor-specific, so I was surprised not to find any discussion of the problem in a few web searches.
As requested by the bug template, I'm using the 64-bit Linux version of Meteor; I doubt it matters.
Reproduction:
debugger
statement (there seems to be a problem with stopping early in server startup).console.log("after");
and stop there.meteor --release=1.6 --inspect
debugger
statement.debugger
statement.f.wait();
and press F10, theconsole.log("after");
executes without the debugger first stopping on that line.The text was updated successfully, but these errors were encountered: