Uh oh!
There was an error while loading. Please reload this page.
src, loader: return promises from link - #18394
Conversation
Fishrock123
commented
Jan 26, 2018
There was a problem hiding this comment.
This should crash if the Set fails (promises->Set().FromJust()). USE is only for when we don’t care about the result of execution, and should be used sparingly.
Why is this patch preferred over #18249 (comment)? Edit: answered on IRC:
|
There was a problem hiding this comment.
If we were to keep a jobs array, we would want to store the promises from getModuleJob to ensure determinism in the order of jobs.
0fbccf9 to
8e1fb42CompareReturns the promises created by link so that they can be awaited to get rid of race conditions while resolving and loading modules.
be04b4a to
f936321Comparedevsnek
commented
Jan 28, 2018
comments above addressed |
BridgeAR
commented
Jan 31, 2018
Returns the promises created by link so that they can be awaited to get rid of race conditions while resolving and loading modules. PR-URL: nodejs#18394 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
BridgeAR
commented
Feb 1, 2018
Landed in edbcf7c |
TimothyGu
commented
Feb 1, 2018
Unfortunately this requires a corresponding change in |
| Local<Promise> resolve_promise = resolve_return_value.As<Promise>(); | ||
| obj->resolve_cache_[specifier_std].Reset(env->isolate(), resolve_promise); | ||
| promises->Set(mod_context, specifier, resolve_promise).FromJust(); |
There was a problem hiding this comment.
This line does not set array items (i.e. it does not set promises[0], promises[1], etc.) It sets promises[specifier] i.e. some non-array properties of promises object. So, the array returned from this function is not populated properly and the corresponding await SafePromise.all(promises) does not do what was expected. There should be i instead of specifier, i.e., promises->Set(mod_context, i, resolve_promise).FromJust();, right?
There was a problem hiding this comment.
yea i actually just caught this while testing my changes for vm.Module. i'm kinda sad this pr landed without tests, as it doesn't work. i have another pr incoming anyway, which will fix this, and includes tests that will actually ensure this behavior does what it is supposed to do.
There was a problem hiding this comment.
Should've caught this while reviewing... my bad as well.
MylesBorins
commented
Feb 20, 2018
This lands cleanly, but is causing v9.x to break during compilation. Should it be backported? |
addaleax
commented
Feb 20, 2018
@MylesBorins These kinds of errors can be fixed by adding |
MylesBorins
commented
Feb 21, 2018
@addaleax thanks, that worked |
Returns the promises created by link so that they can be awaited to get rid of race conditions while resolving and loading modules. PR-URL: #18394 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
This commit fixes up some issues in nodejs#18394. * Switch vm.Module internals to use the new link method properly * Fix bug with ModuleWrap::Link * Add tests for ModuleWrap::Link PR-URL: nodejs#18509Fixes: nodejs#18249 Refs: nodejs#18394 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Returns the promises created by link so that they can be awaited to get rid of race conditions while resolving and loading modules. PR-URL: #18394 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Returns the promises created by link so that they can be awaited to get rid of race conditions while resolving and loading modules. PR-URL: #18394 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
MylesBorins
commented
Mar 20, 2018
Should this be backported to |
Returns the promises created by link so that they can be awaited to get rid of race conditions while resolving and loading modules. PR-URL: nodejs#18394 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
This commit fixes up some issues in nodejs#18394. * Switch vm.Module internals to use the new link method properly * Fix bug with ModuleWrap::Link * Add tests for ModuleWrap::Link PR-URL: nodejs#18509Fixes: nodejs#18249 Refs: nodejs#18394 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Returns the promises created by link so that they can be awaited to get
rid of race conditions while resolving and loading modules.
closes#18249
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
loader, src