Closed
Description
Version
pre-release / nightly
Platform
macOS 12.3.1, M1
Subsystem
esm, loaders
What steps will reproduce the bug?
loader-a.mjs
export function resolve(specifier, context, nextHook) {
assert(nextHook(…) === nextHook(…));
}
How often does it reproduce? Is there a required condition?
100%
A loader hook must call nextHook()
more than once to reproduce.
What is the expected behavior?
nextHook
should be the same within the same loader
What do you see instead?
The first nextHook
is correctly the next in the chain; however, subsequent calls erroneously continue along the hook chain.
Additional information
Thanks @cspotcode for reporting.
Note that this requires loader chaining (#42623), which has not yet been released.
The problem is caused by ESMLoader::resolve()
and ESMLoader::load()
decrementing hookIndex
every time next<HookName>
is called. I believe this can be addressed by using a factory to produce the next<HookName>
and decrementing the counter in there instead.