| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Ping @guybedford? (I've seen that you made most recent changes in this file) |
Sorry, something went wrong.
There was a problem hiding this comment.
This entire code path is a little messy, ideally it could be more like the process.mainModule === cjsModuleInstance comparison to avoid the need to double resolve at all.
If a refactoring could be made to avoid that resolution entirely that would be much much nicer (although would likely require another function argument), but otherwise this approach makes sense to me.
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
This file should be in test/fixtures instead. Ditto for the .ext file.
Sorry, something went wrong.
There was a problem hiding this comment.
I am confused - this only fails if the preload script tries to extend the module resolver right? This comment seems to imply that --require alone can cause failures.
Also it would be better if we could assert the condition under which we allow this to fail. Array.isArray(getOptionValue('--require')) is part of that but there should be more.
Sorry, something went wrong.
There was a problem hiding this comment.
Yes for the first point.
I'm not sure I understand what you mean in the second, can you detail?
Sorry, something went wrong.
There was a problem hiding this comment.
I'm not sure I understand what you mean in the second, can you detail?
I meant we should at least assert(Array.isArray(getOptionValue('--require'))) in the catch block.
Sorry, something went wrong.
There was a problem hiding this comment.
I'm not convinced - this codepath (where resolveArgv is empty and _resolveFilename fails but _compile is called) is only possible for the preloaded scripts anyway (since otherwise _compile won't be called at all if _resolvedFilename fails on the real main entry script).
That said, if you still think it's a blocker, I can add it.
Sorry, something went wrong.
There was a problem hiding this comment.
..is only possible for the preloaded scripts anyway
Yes, exactly, and that's why it should be an assertion - to prevent people from changing this invariant unexpectedly in the future. That happens a lot when code are being moved/copy-pasted around.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed 👍
Sorry, something went wrong.
There was a problem hiding this comment.
I think this comment is redundant now?
Sorry, something went wrong.
At this point, it seems we could specialize the handling of --require a bit since at that point the users cannot monkey-patch module yet and there are certain exceptions (like this one) that should be considered. |
Sorry, something went wrong.
I tried to avoid changing the API as much as possible to avoid potential disruption. It's a fairly small change that can't break anything that was working before, which I think is safer in this situation than a full refactoring. What do you think?
I think we can't do this - it would fail for this kind of setup (but who does that, arguably): node --inspect-brk --require ./foo.js ./foo.js In this situation you will want to break inside foo.js during the preload step, since it won't get executed as main entry point (because it's in the cache). This makes it impossible to wait for the preload list to be fully executed, or to wait for mainModule or similar to be present. Frankly it seems a super fringe use case, but I guess that's the rational behind the way the code is written otherwise I'm not sure why the ahead-of-time resolution was needed in the first place 🤔 |
Sorry, something went wrong.
The resolution for the main entry point may fail when the resolution requires a preloaded module to be executed first (for example when adding new extensions to the resolution process). Silently skipping such failures allow us to defer the resolution as long as needed without having any adverse change (since the main entry point won't resolve anyway if it really can't be resolved at all).
Wait, doesn't the current logic also fail for this case? |
Sorry, something went wrong.
|
In the esm resolver we have an isMain flag which is true through the load operation for the module that corresponds to the main entry into Node.js only - so that's the sort of logic I mean as an alternative. |
Sorry, something went wrong.
No, because the break is execute inside _compile, so even for preloaded module.
There's also a isMain in the cjs loader (in _load). Still, the case described above wouldn't work anymore since the isMain field is only set when executing the main entry point, so not preloaded scripts. The resolution that happens in _compile is from my understanding a way to detect whether the script being compiled will be the main script - before it actually is. |
Sorry, something went wrong.
|
Ah so you suspect this code path was exactly to handle this edge case in the first place, where the main itself could be in the module cache. Although it does seem very much an edge case as opposed to one to be justifying the base-level semantics on, but I guess that is where things are indeed. |
Sorry, something went wrong.
|
Ping? |
Sorry, something went wrong.
Sorry, something went wrong.
|
I'm not sure if the failing tests are related to my diff (I'd assume they aren't, since they're passing most platforms) - can I get some help? |
Sorry, something went wrong.
Sorry, something went wrong.
|
It doesn't look related to me, I've re-triggered the failed builds. |
Sorry, something went wrong.
|
The test failure here seems to be in async hooks - test.node-api/test_make_callback/test-async-hooks-gcable crashed (-11) will try again and see if it works this time. |
Sorry, something went wrong.
|
Actually no, the Travis report is wrong - this is all green. |
Sorry, something went wrong.
The resolution for the main entry point may fail when the resolution requires a preloaded module to be executed first (for example when adding new extensions to the resolution process). Silently skipping such failures allow us to defer the resolution as long as needed without having any adverse change (since the main entry point won't resolve anyway if it really can't be resolved at all). PR-URL: #30336 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
The resolution for the main entry point may fail when the resolution requires a preloaded module to be executed first (for example when adding new extensions to the resolution process). Silently skipping such failures allow us to defer the resolution as long as needed without having any adverse change (since the main entry point won't resolve anyway if it really can't be resolved at all). PR-URL: #30336 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
The resolution for the main entry point may fail when the resolution requires a preloaded module to be executed first (for example when adding new extensions to the resolution process). Silently skipping such failures allow us to defer the resolution as long as needed without having any adverse change (since the main entry point won't resolve anyway if it really can't be resolved at all). PR-URL: #30336 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
The resolution for the main entry point may fail when the resolution requires a preloaded module to be executed first (for example when adding new extensions to the resolution process). Silently skipping such failures allow us to defer the resolution as long as needed without having any adverse change (since the main entry point won't resolve anyway if it really can't be resolved at all). PR-URL: #30336 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
* chore: bump node in DEPS to v12.16.0 * Fixup asar support setup patch nodejs/node#30862 * Fixup InternalCallbackScope patch nodejs/node#30236 * Fixup GN buildfiles patch nodejs/node#30755 * Fixup low-level hooks patch nodejs/node#30466 * Fixup globals require patch nodejs/node#31643 * Fixup process stream patch nodejs/node#30862 * Fixup js2c modification patch nodejs/node#30755 * Fixup internal fs override patch nodejs/node#30610 * Fixup context-aware warn patch nodejs/node#30336 * Fixup Node.js with ltcg config nodejs/node#29388 * Fixup oaepLabel patch nodejs/node#30917 * Remove redundant ESM test patch nodejs/node#30997 * Remove redundant cli flag patch nodejs/node#30466 * Update filenames.json * Remove macro generation in GN build files nodejs/node#30755 * Fix some compilation errors upstream * Add uvwasi to deps nodejs/node#30258 * Fix BoringSSL incompatibilities * Fixup linked module patch nodejs/node#30274 * Add missing sources to GN uv build libuv/libuv#2347 * Patch some uvwasi incompatibilities * chore: bump Node.js to v12.6.1 * Remove mark_arraybuffer_as_untransferable.patch nodejs/node#30549 * Fix uvwasi build failure on win * Fixup --perf-prof cli option error * Fixup early cjs module loading * fix: initialize diagnostics properly nodejs/node#30025 * Disable new esm syntax specs nodejs/node#30219 * Fixup v8 weakref hook spec nodejs/node#29874 * Fix async context timer issue * Disable monkey-patch-main spec It relies on nodejs/node#29777, and we don't override prepareStackTrace. * Disable new tls specs nodejs/node#23188 We don't support much of TLS owing to schisms between BoringSSL and OpenSSL. Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
| Back | FazBrowse Home | New Git URL |
The resolution for the main entry point may fail when the resolution requires
a preloaded module to be executed first (for example when adding new extensions
to the resolution process). Silently skipping such failures allow us to defer
the resolution as long as needed without having any adverse change (since the
main entry point won't resolve anyway if it really can't be resolved at all).
Checklist