feat(vue): Export Vue exception capture helper - #24586
vansh-nagar wants to merge 4 commits into
Conversation
Co-Authored-By: OpenAI/ChatGPT <codex@openai.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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 f52f52b. Configure here.
Co-Authored-By: OpenAI Codex <codex@openai.com>
Co-Authored-By: OpenAI Codex <codex@openai.com>
|
👋 @nicohrubec, @s1gr1d — Please review this PR when you get a chance! |
|
hey @vansh-nagar thanks for opening this PR! do you need this new helper yourself, or did you pick up the issue because it was still open? |
|
Thanks for checking. I picked this up because the issue was still open; I do not currently need the helper in my own project. If the use case is no longer something you want to support, I am happy to close it. Otherwise I can adjust the implementation to match the API you would prefer. |
Co-Authored-By: OpenAI Codex <codex@openai.com>
| // Capture exception in the next event loop, to make sure that all breadcrumbs are recorded in time. | ||
| setTimeout(() => { | ||
| captureException(error, { | ||
| captureContext: { contexts: { vue: metadata } }, | ||
| mechanism: { handled: !!originalErrorHandler, type: 'auto.function.vue.error_handler' }, | ||
| }); | ||
| captureVueExceptionWithMechanism(error, vm, lifecycleHook, !!originalErrorHandler, options); | ||
| }); |
There was a problem hiding this comment.
Bug: Metadata computation is now deferred via setTimeout, which can lead to capturing stale or incomplete component information if the component tree changes before the timer fires.
Severity: LOW
Suggested Fix
Capture the component metadata synchronously when the error is first handled, before scheduling the setTimeout. Pass the collected metadata object into the setTimeout callback. This ensures the metadata reflects the component's state at the exact moment of the error, restoring the previous, more reliable behavior.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: packages/vue/src/errorhandler.ts#L29-L32
Potential issue: The automatic error handler in `attachErrorHandler` now defers the
computation of Vue component metadata to a `setTimeout` callback. Previously, this
metadata was captured synchronously when an error occurred. This change introduces a
potential race condition. If a component's state changes or it unmounts between the
error event and the execution of the `setTimeout` callback on the next event loop tick,
the captured metadata could be stale or incomplete. This can result in a less accurate
component trace, as the logic relies on walking the `$parent` chain which might be
altered, degrading the quality of the error report.
|
@vansh-nagar thanks for getting back to me! I believe this issue went stale for a while and it doesn't seem like more people requested a feature like this in the meantime. I'm going to close the PR, and I just also closed the issue. Sorry for the troubles! If this issue gets reopened, I'm happy to revisit your PR! |

Exports
captureVueExceptionfrom@sentry/vuetogether with itsViewModeltype. The helper applies the same component metadata and mechanism data as the automatic Vue handler, but captures synchronously so anonErrorCapturedboundary can call it insidewithScopewithout losing per-error scope data across a timer.The automatic application handler still defers capture to the next event loop and now shares the metadata-building path with the public helper.
Validated with the focused 14-test Vue error-handler suite, the Vue dependency-aware type build, and type-aware package lint.
Fixes #11471