Repository navigation
Conversation
Native frames from stack-utils parse without a `file` path. Calling normalizeFile(undefined) threw TypeError and hid the original test failure during error serialization. Fixes avajs#3483
4 tasks done
novemberborn
requested changes
Oct 8, 2026
Comment on lines
+54
to
+65
| t.test('Node.js internal stack locations are stable across runtime releases', t => { | ||
| for (const location of ['318:16', '319:16', '346:16', '355:16']) { | ||
| t.equal( | ||
| report.sanitizers.nodeInternalLineNumbers(`compileSourceTextModule (node:internal/modules/esm/utils:${location})`), | ||
| 'compileSourceTextModule (node:internal/modules/esm/utils)', | ||
| ); | ||
| } | ||
|
|
||
| const applicationFrame = 'test (file:///project/test.js:3:1)'; | ||
| t.equal(report.sanitizers.nodeInternalLineNumbers(applicationFrame), applicationFrame); | ||
| t.end(); | ||
| }); |
Member
There was a problem hiding this comment.
I'm cool with not having the line numbers in the logs (unrelated though it is to what this PR fixes), but this test adds no value.
Suggested change
| t.test('Node.js internal stack locations are stable across runtime releases', t => { | |
| for (const location of ['318:16', '319:16', '346:16', '355:16']) { | |
| t.equal( | |
| report.sanitizers.nodeInternalLineNumbers(`compileSourceTextModule (node:internal/modules/esm/utils:${location})`), | |
| 'compileSourceTextModule (node:internal/modules/esm/utils)', | |
| ); | |
| } | |
| const applicationFrame = 'test (file:///project/test.js:3:1)'; | |
| t.equal(report.sanitizers.nodeInternalLineNumbers(applicationFrame), applicationFrame); | |
| t.end(); | |
| }); |
Author
There was a problem hiding this comment.
Dropped the reporter sanitizer and the edge-case log refreshes in 7216266 — they were unrelated to the serialize-error fix. The PR is now only lib/serialize-error.js + test/serialize-error.js.
| import path from 'node:path'; | ||
| import {pathToFileURL} from 'node:url'; | ||
|
|
||
| import {test} from 'tap'; |
Member
There was a problem hiding this comment.
New tests should be under test/.
Author
There was a problem hiding this comment.
Moved in the earlier follow-up — coverage now lives in test/serialize-error.js (and the old test-tap/serialize-error.js path is gone).
Move serialization regressions to test/ and remove the redundant internal stack-location test. Preserve the accepted reporter normalization while resolving upstream snapshot changes. Validated with npm test on Node.js 24.21.0.
Keep the PR focused on extractSource skipping file-less frames. Reporter line-number sanitizing belonged elsewhere and was called out in review.
This branch has not been deployed
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.
This relates to...
Fixes #3483
Rationale
When AVA serializes a failed test error,
extractSourcewalks the stack withstack-utils. Native frames parse to a truthy call site whosefileisundefined. CallingnormalizeFile(undefined)then throwsTypeError: Cannot read properties of undefined (reading 'startsWith'), which crashes error serialization and hides the original failure.Changes
Features
N/A
Bug Fixes
filepath before callingnormalizeFile.<anonymous>file path that must not match the test file.Breaking Changes and Deprecations
N/A
Status
Test plan
npx xo lib/serialize-error.js test-tap/serialize-error.jsnpx tap test-tap/serialize-error.js test-tap/assert.js(846 passed)AI assistance was used while preparing this change.