fix: correct parseNodeArgs and formatNodeOptions processing of NODE_OPTIONS#89968
Draft
runderworld wants to merge 1 commit intovercel:canaryfrom
Draft
fix: correct parseNodeArgs and formatNodeOptions processing of NODE_OPTIONS#89968runderworld wants to merge 1 commit intovercel:canaryfrom
runderworld wants to merge 1 commit intovercel:canaryfrom
Conversation
Collaborator
|
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
Collaborator
|
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
6a30d07 to
d74d4aa
Compare
724c36e to
c4781fd
Compare
…PTIONS Fixes vercel#77550 — Port of PR vercel#71759 to v16.x (canary). The core issue: parseNodeArgs used node:util parseArgs which strips dash prefixes and deduplicates keys. When NODE_OPTIONS contains repeated short options like '-r file1.js -r file2.js', the old code lost values and formatNodeOptions forced '--' prefix on everything (turning '-r' into '--r=', which is invalid in NODE_OPTIONS). Changes: - parseNodeArgs now uses token.rawName to preserve '-' vs '--' prefixes and stores values as arrays to support repeated options - Introduced NodeOptions class wrapping the parsed result with get/set/ delete/has/clone/raw helpers for clean caller interaction - formatNodeOptions updated to handle array values and use the correct separator ('=' for long options, ' ' for short options) - Updated callers in next-dev.ts and worker.ts to use NodeOptions methods - Added tests for repeated -r/--require options (short and long forms), short option formatting, repeated option formatting, and boolean options - Applied Graphite bot suggestion: filter(Boolean) before join in inner map to avoid extra spaces from null values
c4781fd to
8604ded
Compare
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.
What?
Fixes #77550 — Port of PR #71759 to v16.x (canary).
--r=is an invalid value if passed toNODE_OPTIONS, which was the outcome from-r file.jsbecause all options were forcefully prefixed with--and repeated short options (e.g. multiple-r) were deduplicated.Why?
parseNodeArgsandformatNodeOptionsdid not account for:-r a.js -r b.js)-vs--)How?
parseNodeArgsnow usestoken.rawNameto preserve-vs--prefixes and stores values as arrays to support repeated options.NodeOptionsclass wrapping the parsed result withget/set/delete/has/clone/rawhelpers, replacing direct property access on a plain object. This keeps callers clean while supporting the richer internal representation.formatNodeOptionshandles array values and uses the correct separator (=for--longoptions, space for-shortoptions).next-dev.tsandworker.tsto useNodeOptionsmethods.-r/--requireoptions (short and long forms), short option formatting, repeated option formatting, and boolean options.Files changed
packages/next/src/server/lib/utils.tspackages/next/src/server/lib/utils.test.tspackages/next/src/cli/next-dev.tspackages/next/src/lib/worker.tsCredits
Based on the original work by @martinjlowm in #71759 (v15.x), adapted for the v16.x codebase.