Skip to content
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

loader: fix --inspect-brk #18949

Closed
wants to merge 1 commit into from

Conversation

devsnek
Copy link
Member

@devsnek devsnek commented Feb 23, 2018

Fixes: #18948

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

loader

@devsnek
Copy link
Member Author

devsnek commented Feb 23, 2018

@targos
Copy link
Member

targos commented Feb 23, 2018

Could you add a test?

@devsnek
Copy link
Member Author

devsnek commented Feb 23, 2018

side question to anyone who can answer,

why can't we just do something like pauseOnStart() which only calls PauseOnNextJavascriptStatement then calling some function like:

void PauseOnStart(const FunctionCallbackInfo<v8::Value>& args) {
  Environment* env = Environment::GetCurrent(args);
  env->inspector_agent()->PauseOnNextJavascriptStatement("Break on start");
}
if (this.inspectBrk)
  process.binding('inspector').pauseOnStart();
this.module.instantiate();

@TimothyGu TimothyGu added inspector Issues and PRs related to the V8 inspector protocol esm Issues and PRs related to the ECMAScript Modules implementation. labels Feb 23, 2018
Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was actually the original version of the PR submitted by @eugeneo in #17360, before #18194 changed the approach.

Changes LGTM. Testing is necessary however.

@devsnek
Copy link
Member Author

devsnek commented Feb 23, 2018

@targos how does one test inspect-brk? i can't find any similar tests

edit: i found test-inspector-esm.js 👍

@TimothyGu
Copy link
Member

@devsnek Because that would break on this.module.instantiate() rather than the user module.

Copy link
Contributor

@guybedford guybedford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - I just copied the approach from #17360 exactly when doing this initially to get this feature moving. Edit: ah, I see I tried to move the wrapper to avoid an instance property which was the issue here!

I did experiment wrapping the break on the execution function itself to no success, this only seems to be working when wrapping instantiate specifically. If there's a way to get a pauseOnStart going there'd be no reason not to though surely.

Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a test.

@eugeneo
Copy link
Contributor

eugeneo commented Feb 23, 2018

why can't we just do something like pauseOnStart() which only calls PauseOnNextJavascriptStatement then calling some function like:

We can't do it because next JS instruction will be before calling the function. I.e. instead of breaking inside the function (that is a user code) we will arrive to a function callsite, which is framework code. That will confuse the users a lot.

@devsnek
Copy link
Member Author

devsnek commented Feb 23, 2018

i've been messing around with the tests but i just can't figure out this inspector stuff :(

basically the test just needs to be modified to import one other module to ensure nothing is called out of band. i tried to make these changes but i started getting assertion errors from the test inspector wrapper about urls

@guybedford
Copy link
Contributor

@devsnek could you share where exactly the test is giving you issues? It should just be adding another case https://github.com/nodejs/node/blob/master/test/parallel/test-inspector-esm.js#L107, or modifying that existing case to have a dependency right?

@devsnek
Copy link
Member Author

devsnek commented Feb 26, 2018

@guybedford i did that earlier but but it keeps giving me an assertion error here: https://github.com/nodejs/node/blob/master/test/common/inspector-helper.js#L248

and i still really don't understand all this stuff but i've been slowly making my way through the devtools docs

@guybedford
Copy link
Contributor

@devsnek what are the expected and actual values in that case that are failing? If it's pathing issues that may be a test bug.

@devsnek
Copy link
Member Author

devsnek commented Feb 26, 2018

@guybedford i added uh

const depUrl = UrlResolve(session.scriptURL(), 'message.mjs');
session.waitForBreakOnLine(0, depUrl);

which throws an assertion error for module.js === /home/snek/misc/nodejs/node/test/fixtures/es-modules/message.mjs

i also changed loop.mjs to import { message } from './message' and to break on line 6 instead of 5 because of the added line

@guybedford
Copy link
Contributor

@devsnek does the module.js there mean that it's breaking in Node code? And it's definitely working in the Chome devtools correctly?

@devsnek
Copy link
Member Author

devsnek commented Feb 26, 2018

@guybedford i have no idea which module.js it refers to, but yea these changes work perfectly

@nodejs nodejs deleted a comment from 11010110 Feb 26, 2018
@devsnek devsnek force-pushed the fix/esm-main-inspect-brk branch from 0741fcd to 8e6594a Compare March 1, 2018 01:08
@devsnek devsnek force-pushed the fix/esm-main-inspect-brk branch from 8e6594a to 19a0ead Compare March 1, 2018 01:12
@devsnek
Copy link
Member Author

devsnek commented Mar 1, 2018

@guybedford it seems the test i made is working now, i'm running a full test run on my laptop then i'll spin up a ci and if that passes hopefully land this 🙏

@devsnek
Copy link
Member Author

devsnek commented Mar 1, 2018

@addaleax if i land this tonight or tomorrow we can still squeeze it into 9.7.0 right?

@devsnek
Copy link
Member Author

devsnek commented Mar 1, 2018

@devsnek
Copy link
Member Author

devsnek commented Mar 1, 2018

cc @nodejs/build
both windows builds failed around the same time in the middle of what they were doing with FATAL: command execution failed java.nio.channels.ClosedChannelException

@addaleax
Copy link
Member

addaleax commented Mar 1, 2018

@devsnek Sorry, I wasn’t around when you posted that comment – if you think something is important enough to let a release wait for it, commenting in the release proposal might be best…

Then again, I’d be happy to also prepare another 9.x release next week.

@devsnek
Copy link
Member Author

devsnek commented Mar 1, 2018

landed in abd0d79

@devsnek devsnek closed this Mar 1, 2018
@devsnek devsnek deleted the fix/esm-main-inspect-brk branch March 1, 2018 15:19
devsnek added a commit that referenced this pull request Mar 1, 2018
PR-URL: #18949
Fixes: #18948
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@devsnek devsnek mentioned this pull request Mar 2, 2018
addaleax pushed a commit to addaleax/node that referenced this pull request Mar 5, 2018
PR-URL: nodejs#18949
Fixes: nodejs#18948
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Mar 6, 2018
MylesBorins added a commit that referenced this pull request Mar 6, 2018
Notable Changes:

* crypto:
  - add cert.fingerprint256 as SHA256 fingerprint (Hannes Magnusson)
    #17690
* lib:
  - v8_prof_processor works again 🎉 (Anna Henningsen)
    #19059
* loader:
  - --inspect-brk now works properly for esmodules (Gus Caplan)
    #18949
* src:
  - handle exceptions in env-\>SetImmediates (James M Snell)
    #18297
  - make process.dlopen() load well-known symbol (Ben Noordhuis)
    #18934
* trace_events:
  - add file pattern cli option (Andreas Madsen)
    #18480

PR-URL: #19181
MylesBorins added a commit that referenced this pull request Mar 7, 2018
Notable Changes:

* crypto:
  - add cert.fingerprint256 as SHA256 fingerprint (Hannes Magnusson)
    #17690
* lib:
  - v8_prof_processor works again 🎉 (Anna Henningsen)
    #19059
* loader:
  - --inspect-brk now works properly for esmodules (Gus Caplan)
    #18949
* src:
  - handle exceptions in env-\>SetImmediates (James M Snell)
    #18297
  - make process.dlopen() load well-known symbol (Ben Noordhuis)
    #18934
* trace_events:
  - add file pattern cli option (Andreas Madsen)
    #18480

PR-URL: #19181
MylesBorins added a commit that referenced this pull request Mar 7, 2018
Notable Changes:

* crypto:
  - add cert.fingerprint256 as SHA256 fingerprint (Hannes Magnusson)
    #17690
* http2:
  - Fixed issues with aborted connections in the HTTP/2 implementation
    (Anna Henningsen)
    #18987
    #19002
* loader:
  - --inspect-brk now works properly for esmodules (Gus Caplan)
    #18949
* src:
  - make process.dlopen() load well-known symbol (Ben Noordhuis)
    #18934
* trace_events:
  - add file pattern cli option (Andreas Madsen)
    #18480
* Added new collaborators:
  - Chen Gang (MoonBall) https://github.com/MoonBall

PR-URL: #19181
MylesBorins added a commit that referenced this pull request Mar 8, 2018
Notable Changes:

* crypto:
  - add cert.fingerprint256 as SHA256 fingerprint (Hannes Magnusson)
    #17690
* http2:
  - Fixed issues with aborted connections in the HTTP/2 implementation
    (Anna Henningsen)
    #18987
    #19002
* loader:
  - --inspect-brk now works properly for esmodules (Gus Caplan)
    #18949
* src:
  - make process.dlopen() load well-known symbol (Ben Noordhuis)
    #18934
* trace_events:
  - add file pattern cli option (Andreas Madsen)
    #18480
* Added new collaborators:
  - Chen Gang (MoonBall) https://github.com/MoonBall

PR-URL: #19181
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
PR-URL: nodejs#18949
Fixes: nodejs#18948
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
Notable Changes:

* crypto:
  - add cert.fingerprint256 as SHA256 fingerprint (Hannes Magnusson)
    nodejs#17690
* http2:
  - Fixed issues with aborted connections in the HTTP/2 implementation
    (Anna Henningsen)
    nodejs#18987
    nodejs#19002
* loader:
  - --inspect-brk now works properly for esmodules (Gus Caplan)
    nodejs#18949
* src:
  - make process.dlopen() load well-known symbol (Ben Noordhuis)
    nodejs#18934
* trace_events:
  - add file pattern cli option (Andreas Madsen)
    nodejs#18480
* Added new collaborators:
  - Chen Gang (MoonBall) https://github.com/MoonBall

PR-URL: nodejs#19181
@jasnell
Copy link
Member

jasnell commented Aug 17, 2018

Should this be backported to 8.x?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. inspector Issues and PRs related to the V8 inspector protocol
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants