Skip to content

path: avoid mutable push in join() - #67752

Open
rozzilla wants to merge 2 commits into
nodejs:mainfrom
rozzilla:path-join-no-push
Open

rozzilla wants to merge 2 commits into
nodejs:mainfrom
rozzilla:path-join-no-push

Conversation

@rozzilla

Copy link
Copy Markdown
Contributor

posix.join() and the reserved-name check in win32.join() collected segments with .push() on local arrays, which looks up Array.prototype.push at call time. Use indexed assignments instead. Similar PR as #67748

posix.join() and the reserved-name check in win32.join() collected
segments with .push() on local arrays, which looks up
Array.prototype.push at call time. Replacing that method from user code
made path.join() throw or return a wrong path. Use indexed assignments
instead. win32.join() already uses ArrayPrototypePush for its own
segment list.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/path

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. path Issues and PRs related to the path subsystem. labels Nov 24, 2026
@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.50%. Comparing base (a055d9f) to head (dc74f52).
⚠️ Report is 96 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67752      +/-   ##
==========================================
- Coverage   90.52%   90.50%   -0.02%     
==========================================
  Files         803      805       +2     
  Lines      285110   285756     +646     
  Branches    55037    55166     +129     
==========================================
+ Hits       258101   258632     +531     
- Misses      17143    17220      +77     
- Partials     9866     9904      +38     
Files with missing lines Coverage Δ
lib/path.js 97.55% <100.00%> (ø)

... and 59 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
@Renegade334 Renegade334 added the commit-queue-squash PRs the Commit Queue should land as one squashed commit. label Nov 25, 2026

@ljharb ljharb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are all these being done as separate PRs?

@gurgunday gurgunday left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rozzilla

Copy link
Copy Markdown
Contributor Author

why are all these being done as separate PRs?

@ljharb I split them on purpose after #67456. That PR started as an ArrayPrototypePush rewrite across lib/, and @LiviaMedeiros objected to the readability and consistency cost of a lib-wide change (#67456 (comment)). The suggestion was to keep changes scoped and, separately, use indexed assignments to protect code that doesn't use primordials from Array.prototype.push mutations (#67456 (comment)). One subsystem per PR keeps each case easy to judge on its own.

There are a few more private arrays left (http, stream and BlockList, about 18 call sites). I'm happy to send those as a single PR if that's preferred.

@gurgunday gurgunday added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Nov 28, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 28, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@inoway46 inoway46 added the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 29, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 29, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue-squash PRs the Commit Queue should land as one squashed commit. needs-ci PRs that need a full CI run. path Issues and PRs related to the path subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants