node icon indicating copy to clipboard operation
node copied to clipboard

lib: fix module print timing when specifier includes `"`

Open aduh95 opened this issue 1 year ago β€’ 5 comments

Currently, we generate invalid JSON if the specifier contains ", this can be addressed by escaping all double quotes like this PR is doing.

aduh95 avatar Sep 28 '24 13:09 aduh95

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 88.18%. Comparing base (f5d454a) to head (bda9e62). Report is 917 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #55150      +/-   ##
==========================================
- Coverage   88.23%   88.18%   -0.05%     
==========================================
  Files         651      649       -2     
  Lines      183902   183327     -575     
  Branches    35855    35686     -169     
==========================================
- Hits       162269   161672     -597     
- Misses      14926    15024      +98     
+ Partials     6707     6631      -76     
Files with missing lines Coverage Ξ”
lib/internal/util/debuglog.js 95.20% <100.00%> (ΓΈ)

... and 56 files with indirect coverage changes

codecov[bot] avatar Sep 28 '24 14:09 codecov[bot]

From what I remember, almost all places that use/expose trace labels are susceptible to this issue, I don't remember exactly the places but I think could be something worthy to take a double look.

Fixing this implementation also fixes the console.time implementation, so if you want to include a test there too, could be useful.

H4ad avatar Sep 28 '24 22:09 H4ad

Fixing this implementation also fixes the console.time implementation, so if you want to include a test there too, could be useful.

Do you have an example? Naive testing (node -e 'console.time(`test"`);console.timeEnd(`test"`)') doesn't show the issue.

aduh95 avatar Sep 28 '24 23:09 aduh95

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

nodejs-github-bot avatar Sep 29 '24 08:09 nodejs-github-bot

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

nodejs-github-bot avatar Sep 29 '24 12:09 nodejs-github-bot

@aduh95 node --trace-event-categories -e 'console.time(`test"`);console.timeEnd(`test"`)'

The generated logs are in json, and the json file is broken.

Edit2: I'm okay with adding tests in another PR (since the CI of this PR is already green)

H4ad avatar Sep 30 '24 13:09 H4ad

Landed in 78f421de886b80be099e597845d8b3235200fdfa

nodejs-github-bot avatar Oct 08 '24 16:10 nodejs-github-bot

Tentatively backport in https://github.com/nodejs/node/pull/56927 to reduce conflicts. Though this is not very essential and might get dropped.

joyeecheung avatar Feb 06 '25 01:02 joyeecheung

Backing it out from https://github.com/nodejs/node/pull/56927 to avoid introducing surface for regressions.

joyeecheung avatar Feb 06 '25 12:02 joyeecheung