node icon indicating copy to clipboard operation
node copied to clipboard

lib,src: isInsideNodeModules should test on the first non-internal frame

Open legendecas opened this issue 2 weeks ago β€’ 5 comments

Avoid checking up to 100 frames every time on functions like require('node:url').parse, when the user application never invokes them with --disable-deprecation=DEP0169 is present (so urlParseWarned will never be true).

Before https://github.com/nodejs/node/pull/55286, isInsideNodeModules only checks the topmost non-internal frame. This restores the original behavior.

https://github.com/nodejs/node/blob/6e474c024c85d9a93db40020dacd20a768c62369/lib/url.js#L135

legendecas avatar Dec 08 '25 12:12 legendecas

Review requested:

  • [ ] @nodejs/loaders
  • [ ] @nodejs/performance
  • [ ] @nodejs/url

nodejs-github-bot avatar Dec 08 '25 12:12 nodejs-github-bot

Not for this PR, though it seems useful to have a helper specifically for deprecations and other one-off warnings that skips the check if it's disabled/already emitted/checked enough times.

joyeecheung avatar Dec 08 '25 13:12 joyeecheung

Codecov Report

:x: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 88.52%. Comparing base (6e474c0) to head (780517c). :warning: Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
src/node_util.cc 71.42% 0 Missing and 2 partials :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #60991      +/-   ##
==========================================
- Coverage   88.52%   88.52%   -0.01%     
==========================================
  Files         703      703              
  Lines      208430   208424       -6     
  Branches    40206    40197       -9     
==========================================
- Hits       184513   184501      -12     
+ Misses      15947    15937      -10     
- Partials     7970     7986      +16     
Files with missing lines Coverage Ξ”
lib/buffer.js 100.00% <100.00%> (ΓΈ)
lib/internal/modules/cjs/loader.js 97.97% <100.00%> (-0.05%) :arrow_down:
lib/punycode.js 94.72% <100.00%> (ΓΈ)
lib/url.js 100.00% <100.00%> (ΓΈ)
src/node_util.cc 80.95% <71.42%> (+0.95%) :arrow_up:

... and 39 files with indirect coverage changes

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

codecov[bot] avatar Dec 08 '25 14:12 codecov[bot]

CI: https://ci.nodejs.org/job/node-test-pull-request/70435/

nodejs-github-bot avatar Dec 08 '25 16:12 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/70440/

nodejs-github-bot avatar Dec 08 '25 20:12 nodejs-github-bot

Commit Queue failed
- Loading data for nodejs/node/pull/60991
βœ”  Done loading data for nodejs/node/pull/60991
----------------------------------- PR info ------------------------------------
Title      lib,src: isInsideNodeModules should test on the first non-internal frame (#60991)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     legendecas:benchmark-isinsidenodemodules -> nodejs:main
Labels     c++, lib / src, author ready, needs-ci, lts-watch-v20.x, lts-watch-v22.x
Commits    2
 - benchmark: add microbench on isInsideNodeModules
 - lib,src: isInsideNodeModules should test on the first non-internal frame
Committers 1
 - Chengzhong Wu <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/60991
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/60991
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
--------------------------------------------------------------------------------
   β„Ή  This PR was created on Mon, 08 Dec 2025 12:55:51 GMT
   βœ”  Approvals: 4
   βœ”  - Joyee Cheung (@joyeecheung) (TSC): https://github.com/nodejs/node/pull/60991#pullrequestreview-3552088477
   βœ”  - Marco Ippolito (@marco-ippolito) (TSC): https://github.com/nodejs/node/pull/60991#pullrequestreview-3552116038
   βœ”  - Daniel Lemire (@lemire): https://github.com/nodejs/node/pull/60991#pullrequestreview-3552297116
   βœ”  - Colin Ihrig (@cjihrig): https://github.com/nodejs/node/pull/60991#pullrequestreview-3552456556
   βœ”  Last GitHub CI successful
   β„Ή  Last Full PR CI on 2025-12-08T20:51:07Z: https://ci.nodejs.org/job/node-test-pull-request/70440/
- Querying data for job/node-test-pull-request/70440/
   βœ”  Last Jenkins CI successful
--------------------------------------------------------------------------------
   βœ”  No git cherry-pick in progress
   βœ”  No git am in progress
   βœ”  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
βœ”  origin/main is now up-to-date
- Downloading patch for 60991
From https://github.com/nodejs/node
 * branch                  refs/pull/60991/merge -> FETCH_HEAD
βœ”  Fetched commits as 83ba6b107a06..780517cbdf8d
--------------------------------------------------------------------------------
[main 7e6314c3be] benchmark: add microbench on isInsideNodeModules
 Author: Chengzhong Wu <[email protected]>
 Date: Mon Dec 8 12:19:55 2025 +0000
 1 file changed, 52 insertions(+)
 create mode 100644 benchmark/internal/util_isinsidenodemodules.js
Auto-merging lib/internal/modules/cjs/loader.js
[main cebd76f992] lib,src: isInsideNodeModules should test on the first non-internal frame
 Author: Chengzhong Wu <[email protected]>
 Date: Mon Dec 8 12:36:38 2025 +0000
 8 files changed, 58 insertions(+), 29 deletions(-)
 create mode 100644 test/parallel/test-internal-util-isinsidenodemodules.js
   βœ”  Patches applied
There are 2 commits in the PR. Attempting autorebase.
(node:2398) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Rebasing (2/4)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
benchmark: add microbench on isInsideNodeModules

PR-URL: https://github.com/nodejs/node/pull/60991 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>

[detached HEAD 1ceb3af622] benchmark: add microbench on isInsideNodeModules Author: Chengzhong Wu <[email protected]> Date: Mon Dec 8 12:19:55 2025 +0000 1 file changed, 52 insertions(+) create mode 100644 benchmark/internal/util_isinsidenodemodules.js Rebasing (3/4) Rebasing (4/4) Executing: git node land --amend --yes --------------------------------- New Message ---------------------------------- lib,src: isInsideNodeModules should test on the first non-internal frame

PR-URL: https://github.com/nodejs/node/pull/60991 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>

[detached HEAD ae6a956b81] lib,src: isInsideNodeModules should test on the first non-internal frame Author: Chengzhong Wu <[email protected]> Date: Mon Dec 8 12:36:38 2025 +0000 8 files changed, 58 insertions(+), 29 deletions(-) create mode 100644 test/parallel/test-internal-util-isinsidenodemodules.js Successfully rebased and updated refs/heads/main.

β„Ή Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/20099802384

nodejs-github-bot avatar Dec 10 '25 13:12 nodejs-github-bot

Landed in 83ba6b107a067f5831b03ab69c787fcb35bdcb05...32ea48d74993c323664e9f62acafba3c8661ad37

nodejs-github-bot avatar Dec 10 '25 13:12 nodejs-github-bot