Skip to content

Tell where --js code failed in a module with --verbose to close #824 - #829

Merged
mathiasrw merged 12 commits into
mainfrom
fix/824
Oct 23, 2026
Merged

mathiasrw merged 12 commits into
mainfrom
fix/824

Conversation

@mathiasrw

@mathiasrw mathiasrw commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Closes #824

Stacked on #828.

Change

Since #808, --js code that fails only gives the message. With --verbose it now also tells where, when that is in a file of the user, like a module loaded with r():

 ❌ The code of --js failed for the piped data: TypeError: undefined is not an object (evaluating 'value.nope.deeper')
    at helper.js:2:15
    No further processing.
  • It is the first place in the stack above the code of RexReplace, which is where the code of the user runs. Places in Node itself are skipped. The path is relative to the working folder.
  • Code in the command itself (like nope()) has no such place, so nothing more is told.
  • It works the same on Node and Bun, which write the stack in different ways.

Tests

test/fix/824.test.js is new. yarn test-ci passes.

From the review of 23 October.

After the review of 24 October

  • Reading the stack is in a try, so a thrown value whose getters throw no longer crashes the run with --verbose. Before, it undid Better error handling of --js code for none error throws to close #822 #828 for that flag.
  • Each line of the stack is read on its own, with the place at the end of the line, so a path with parentheses, like a (copy)/helper.js, is read as a whole.
  • Only absolute paths count, so the frames of Node itself (node:internal/…) and of code run with eval are not shown as fake ../../ paths. Paths in node_modules are skipped too.
  • Checked on Node and Bun: a module, a path with parentheses, a module that is not there, new URL("x"), nope() and a Proxy that throws.

After the review of 24 October

Closes #846

  • A stack line without a function name, like at /dir/a (copy)/top.js:1:11, is read first as that form, as the place comes right after at. Before, /dir/a ( was read as the name of a function, and the place was not told. A line with a name has its place in parentheses at the end, and is read as that form.
  • Checked on Bun and Node, with code at the top of a module and in a function, in a folder with parentheses in its name.

Follow-up

  • The error is on its own line under the file, with no colon:
 ❌ The code of --js failed for the piped data
    TypeError: undefined is not an object (evaluating 'value.nope.deeper')
    at helper.js:2:15
    No further processing.

@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 13:13
@mathiasrw
mathiasrw added this pull request to stack #841 October 23, 2026 13:56
@mathiasrw
mathiasrw marked this pull request as draft October 23, 2026 14:14
@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 14:22
@mathiasrw
mathiasrw marked this pull request as draft October 23, 2026 14:53
@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 14:57
@mathiasrw
mathiasrw marked this pull request as draft October 23, 2026 15:23
@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 15:50
@mathiasrw
mathiasrw force-pushed the fix/822 branch 4 times, most recently from 8ae75e8 to f509676 Compare October 23, 2026 15:55
@mathiasrw
mathiasrw removed this pull request from stack #841 October 23, 2026 15:57
@mathiasrw
mathiasrw changed the base branch from fix/822 to main October 23, 2026 15:57
@mathiasrw
mathiasrw marked this pull request as draft October 23, 2026 15:59
@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 16:03
@mathiasrw
mathiasrw merged commit 2d9a12a into main Oct 23, 2026
7 checks passed
@mathiasrw
mathiasrw deleted the fix/824 branch October 23, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix --verbose missing the place in a stack line without a function name Fix --verbose not telling where --js code failed in a module

1 participant