-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
module: fix ERR_INTERNAL_ASSERTION in CJS module loading #60408
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
base: main
Are you sure you want to change the base?
Conversation
…_ASSERTION in CJS module loading Fixes: nodejs#60401 The loadCJSModule function was not properly validating source content before passing it to compileFunctionForCJSLoader, causing internal assertions when source was null or undefined. This change adds proper source validation and throws a meaningful ERR_INVALID_RETURN_PROPERTY_VALUE error instead of failing with an internal assertion.
|
Review requested:
|
Could you add a test? |
Add test cases to verify that loadCJSModule properly handles null, undefined, and empty string source values by throwing ERR_INVALID_RETURN_PROPERTY_VALUE instead of triggering ERR_INTERNAL_ASSERTION. Tests three scenarios: - Custom loader returning null source - Custom loader returning undefined source - Custom loader returning empty string source Refs: nodejs#60401
done, added test case in second commit to verify the fix works correctly. The test covers null, undefined, and empty string source values to ensure ERR_INVALID_RETURN_PROPERTY_VALUE is thrown instead of ERR_INTERNAL_ASSERTION. @aduh95 |
|
Friendly ping @nodejs/loaders - would appreciate any feedback when you have time! |
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #60408 +/- ##
==========================================
+ Coverage 88.56% 88.58% +0.01%
==========================================
Files 704 704
Lines 207774 207841 +67
Branches 40027 40043 +16
==========================================
+ Hits 184020 184120 +100
+ Misses 15800 15765 -35
- Partials 7954 7956 +2
🚀 New features to boost your workflow:
|
|
@aduh95 I've made some changes, checks are needed again |
|
Friendly ping @aduh95 - would appreciate any feedback when you have time! |
Description
Fixes #60401
The
loadCJSModulefunction inlib/internal/modules/esm/translators.jswas not validating source content before passing it to the nativecompileFunctionForCJSLoaderfunction. When source wasnullorundefined, this caused an internal assertion failure instead of throwing a meaningful error.Changes
loadCJSModuleto check for null/undefined/empty sourceERR_INVALID_RETURN_PROPERTY_VALUEwith descriptive message instead of internal assertionTesting
The validation prevents the internal assertion that was occurring with custom loaders returning null source.
test/parallel/test-esm-loader-null-source.jsChecklist
make -j4 test(UNIX) orvcbuild test(Windows) passes (will be verified by CI)