fix(core): preserve custom .stack getters in error/test formatter#35246
Merged
Conversation
Errors that provide a custom `.stack` (e.g. Effect or other fiber runtimes, or a manually assigned value) were rendered with an internal call-site frame instead of their custom stack. `console.error` already showed the rich stack because it formats via the `.stack` string, but letting the error bubble to the top-level handler or fail a test discarded it, since those paths render only the structured frames read from the private #callSiteEvals array. When accessing `.stack` does not populate #callSiteEvals, the stack was not produced by our prepareStackTrace, so the structured frames are not authoritative. Mark such errors with a new `stack_is_custom` flag on JsError and have the formatter emit the custom `.stack` string instead, matching Node.js. Closes #35243
The stack_is_custom heuristic flagged any frame-less error whose .stack spans more than one line. An error with a multi-line message (e.g. the "Unsupported scheme ... Supported schemes:" list) has no frames and a multi-line .stack that is just its "name: message" string, so it was wrongly classified as custom and the formatter re-emitted the message tail, duplicating it. Compare .stack against the default "name: message" representation and only treat it as custom when it carries content beyond that header, so a multi-line message is no longer mistaken for a stack.
bartlomieju
enabled auto-merge (squash)
June 17, 2026 08:39
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.
Errors that expose a custom `.stack` getter, such as those produced by
Effect and other fiber runtimes, or a manually assigned `.stack` string,
were rendered with a single internal call-site frame instead of the
custom stack. `console.error` already showed the rich stack because it
formats via the `.stack` string, but letting the same error bubble to
the top-level handler or fail a test discarded it: those paths render
only the structured frames read from the private `#callSiteEvals` array,
which a custom `.stack` never populates.
When accessing `.stack` does not populate `#callSiteEvals`, the stack was
not produced by our `prepareStackTrace`, so the structured frames are not
authoritative. This marks such errors with a new `stack_is_custom` flag
on `JsError` and has the formatter emit the custom `.stack` string in
that case, matching Node.js.
Closes #35243