Skip to content

fix(vue): prevent after hook from starting new span #4438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 24, 2022

Conversation

datbth
Copy link
Contributor

@datbth datbth commented Jan 21, 2022

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

Fix issue similar to #4427, where:

  1. The 'before' hook is triggered before Vue routing happens, hence 'pageload' transaction has not started and the tracking span is not created
  2. The 'after' hook is called afterwards. But because there is no corresponding tracking span, the handler starts a new tracking span
  3. The new tracking span never finishes and eventually gets marked as 'cancelled'

Notes:

  • Currently, I have only actually experienced this issue with ui.vue.activate

I'm not able to find any existing tracing tests, so please tell me what I should do with the testing if necessary.

@datbth datbth force-pushed the vue/fix_orphaned_tracing branch from 074fdb9 to ac72ee4 Compare January 21, 2022 09:34
Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for the PR!

We don't have amazing test coverage for Vue, I opened a issue to track it: #4440

I would leave the PR without tests for now, but help for tests are always appreciated!

@@ -66,7 +66,9 @@ export const createTracingMixins = (options: TracingOptions): Mixins => {
continue;
}

for (const internalHook of internalHooks) {
internalHooks.forEach((internalHook, hookType) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change to forEach?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is meant to retrieve hookType. Are you thinking checking internalHook === internalHooks[1] would suffice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have discarded the change and updated to compare internalHook with internalHooks directly.

@@ -66,7 +66,9 @@ export const createTracingMixins = (options: TracingOptions): Mixins => {
continue;
}

for (const internalHook of internalHooks) {
internalHooks.forEach((internalHook, hookType) => {
const isBeforeHook = hookType === 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this need to be a variable? Only used once in the if statement - and I think the meaning is pretty clear without the need of a variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok let me update it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@AbhiPrasad AbhiPrasad added the Package: vue Issues related to the Sentry Vue SDK label Jan 21, 2022
@datbth datbth force-pushed the vue/fix_orphaned_tracing branch from ac72ee4 to 093de9f Compare January 24, 2022 06:04
@datbth datbth requested a review from AbhiPrasad January 24, 2022 06:05
@AbhiPrasad AbhiPrasad enabled auto-merge (squash) January 24, 2022 14:26
@AbhiPrasad AbhiPrasad merged commit 6a10759 into getsentry:master Jan 24, 2022
@datbth datbth deleted the vue/fix_orphaned_tracing branch January 25, 2022 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: vue Issues related to the Sentry Vue SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants