src: omit unconvertible names in cjs_lexer::Parse#63943
Open
anonrig wants to merge 1 commit into
Open
Conversation
Follow-up to aa25a0a. When an export or re-export name cannot be converted to a V8 string (e.g. on string allocation failure), omit that individual name and continue instead of bailing out of the whole preparse. A single pathological name no longer fails the module's exports preparse; the remaining names are still returned. Refs: nodejs#63885 Refs: nodejs#63323 Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
watilde
approved these changes
Jun 16, 2026
Collaborator
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.
Follow-up to #63885 (
aa25a0a30c3).That change made
CreateString()return aMaybeLocal<String>and bailed out ofParse()(earlyreturn) when an export / re-export name could not be converted to a V8 string or whenSet::Add()failed. Because the binding then returnsundefined, the JS caller (cjsPreparseModuleExportsinlib/internal/modules/esm/translators.js, which doesconst { 0: exportNames, 1: reexports } = cjsParse(source)) fails the entire exports preparse for that module.This makes the conversion best-effort instead: omit any individual export / re-export name that cannot be turned into a V8 string and continue, so the remaining names are still returned and a single pathological name no longer fails the whole preparse.
Set::Add()is aV8_WARN_UNUSED_RESULT, so its result is explicitly discarded withUSE().Verified locally:
node_cjs_lexer.ccbuilds clean,cpplintpasses, thecjs_lexerbinding returns the expected export/re-export names (ASCII + non-ASCII) and handlesnull/empty input, andtest/es-moduleCJS-exports tests pass.Refs: #63885
Refs: #63323