feat(core)!: Default attachStacktrace to true#22572
Conversation
Attach synthetic stack traces by default for message/string-derived events. Explicit `attachStacktrace: false` still opts out. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
size-limit report 📦
|
Add browser + node integration suites asserting `attachStacktrace: false` produces no stack trace, and reword the option JSDoc to reflect that it also applies to non-Error values passed to captureException. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
With attachStacktrace now defaulting to true, message events gained a synthetic exception. This broke tests that assert message events have no exception (browser captureConsole, cloudflare http-server, deno snapshots) and node scope/DSC tests whose strict envelope ordering shifted because the synthetic stack trace triggers async ContextLines source reads. None of these tests concern stack traces, so opt them out with attachStacktrace: false rather than reworking their assertions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| Sentry.init({ | ||
| dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
| integrations: [captureConsoleIntegration()], | ||
| attachStacktrace: false, |
There was a problem hiding this comment.
opted out some tests that are not directly about the stacktrace before to not have to adjust the assertions, but can also switch this if we prefer to test the default case everywhere
There was a problem hiding this comment.
I think you found a good balance of opting some tests out of the change while adjusting some others. No objections!
…on inputs
With attachStacktrace defaulting to true, non-Error values passed to
captureException (e.g. a Response) now hit the exception-building branch in
eventFromString, which set `value` to the raw object (serialized to `{}`)
instead of the readable `[object Response]` string. Pass the stringified
input so the value matches the pre-existing behavior. Also bump the deno
captureException snapshot line numbers shifted by the test-only opt-out.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…e suites An audit of all node-integration suites found four more that fire multiple captureMessage calls and assert them in strict envelope order. With the synthetic stack trace now attached by default, async ContextLines source reads race and reorder emission, flaking these tests. Opt them out with attachStacktrace: false like the others; none concern stack traces. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| // | ||
| // So bail out and capture it as a simple message: | ||
| event = eventFromString(stackParser, exception as string, syntheticException, attachStacktrace); | ||
| event = eventFromString(stackParser, `${exception}`, syntheticException, attachStacktrace); |
There was a problem hiding this comment.
the exception string here sets event.exception.values[0].value, without this change e.g. a new Response() input to captureException() gets set directly here which is then serialized to {} instead of [object Response]
| Sentry.init({ | ||
| dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
| integrations: [captureConsoleIntegration()], | ||
| attachStacktrace: false, |
There was a problem hiding this comment.
I think you found a good balance of opting some tests out of the change while adjusting some others. No objections!
chargome
left a comment
There was a problem hiding this comment.
Wondering if we should also incorporate frameContextLines here?
…ctor Set attachStacktrace to true once in the base Client constructor instead of asserting `!== false` at each stacktrace guard. The guards revert to plain truthy checks and every SDK client inherits the default via super(). This is easier to reason about and slightly smaller. Move the message default-on assertion to a client-level browser test, since the eventFromMessage helper no longer defaults on its own. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5ee1271. Configure here.
…puts
`${exception}` throws a TypeError for Symbol inputs. Use String() instead,
which safely handles Symbols while producing identical output for all other
values. This was a pre-existing issue on the addExceptionTypeValue line.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…acktrace The pre-existing "should capture an message" test asserted no exception but only passed due to the empty stackParser, reading as a contradiction with the new default-case test beside it. Set attachStacktrace: false so the assertion reflects the opt-out path explicitly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Broaden the v10->v11 migration entry to cover non-Error captureException inputs and to call out that message/console events now mark sessions as errored (not crashed), plus the Logs alternative for informational messages. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@chargome if I understand correctly this is about attaching the stack frames and |
The exact-match getOptions() assertion now needs the attachStacktrace: true default injected by the base Client constructor. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
attachStacktrace to trueattachStacktrace to true

attachStacktrace: trueis now the default. Stack traces are attached to message/string-derived events unless a user explicitly setsattachStacktrace: false.This by default attaches a synthetic stack trace in three cases going forward:
captureMessage(...): always (browser + server).captureException(<non-Error primitive, e.g. a string>): browser only (server already attached one unconditionally).captureException(<DOMException/DOMError with a .stack>): browser only.Closes #21188