Skip to content

Browser async context gets lost after second await #5914

@patroza

Description

@patroza

What happened?

In the browser we're losing spans on the second, same level, await.
But not for nested awaits. This is with the ZoneContextManager

Steps to Reproduce

https://stackblitz.com/edit/tanstack-form-looses-otel-context-k89k2seu?file=src%2FApp.vue,src%2Fmain.ts,src%2Frepro.ts

Expected Result

Console:

repro SpanImpl {_spanContext: {…}, kind: 0, parentSpanContext: undefined, attributes: {…}, links: Array(0), …}
general SpanImpl {_spanContext: {…}, kind: 0, parentSpanContext: undefined, attributes: {…}, links: Array(0), …}
test1 SpanImpl {_spanContext: {…}, kind: 0, parentSpanContext: undefined, attributes: {…}, links: Array(0), …}
test2 SpanImpl {_spanContext: {…}, kind: 0, parentSpanContext: undefined, attributes: {…}, links: Array(0), …}
general.end SpanImpl {_spanContext: {…}, kind: 0, parentSpanContext: undefined, attributes: {…}, links: Array(0), …}

Actual Result

repro SpanImpl {_spanContext: {…}, kind: 0, parentSpanContext: undefined, attributes: {…}, links: Array(0), …}
general SpanImpl {_spanContext: {…}, kind: 0, parentSpanContext: undefined, attributes: {…}, links: Array(0), …}
test1 SpanImpl {_spanContext: {…}, kind: 0, parentSpanContext: undefined, attributes: {…}, links: Array(0), …}
test2 undefined
general.end undefined

Additional Details

It started out with trying to find out why with @tanstack/vue-form, the handleSubmit span was no longer available at the onSubmit callback. But as the repro shows, it happens just with plain javascript too.

See the repro for all the details.

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocumentDocumentation-relatedpriority:p2Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions