Repository navigation
Fail missing, unmocked imports with ERR_MODULE_NOT_FOUND, not ENOENT - #129
Merged
Merged
Conversation
Fixes #100 So that missing modules can be mocked, recoverResolve turns Node's ERR_MODULE_NOT_FOUND into a made-up URL. When nothing mocks that URL, the load hook passed it to nextLoad, which threw ENOENT instead. Save the resolve error and rethrow it from the load hook when the URL isn't mocked. It's keyed by the URL without its query, because on Node 26+ the registerHooks() hooks run alongside --loader=quibble and re-tag the URL before it reaches the off-thread load hook. A successful resolve of the same URL forgets the error, so a file created later still loads.
rosston
marked this pull request as ready for review
October 12, 2026 15:15
Member
Author
|
The only tests failing in the testdouble.js integration test are the ones asserting a |
This was referenced Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #100
So that missing modules can be mocked, recoverResolve turns Node's ERR_MODULE_NOT_FOUND into a made-up URL. When nothing mocks that URL, the load hook passed it to nextLoad, which threw ENOENT instead.
Save the resolve error and rethrow it from the load hook when the URL isn't mocked. It's keyed by the URL without its query, because on Node 26+ the registerHooks() hooks run alongside --loader=quibble and re-tag the URL before it reaches the off-thread load hook. A successful resolve of the same URL forgets the error, so a file created later still loads.