Skip to content

fix(diagnostics): emit asyncStart after promise settlement to match native tracePromise#4824

Merged
yaacovCR merged 1 commit into
graphql:17.x.xfrom
logaretm:tracing/async-start-emission-timing
Jun 16, 2026
Merged

fix(diagnostics): emit asyncStart after promise settlement to match native tracePromise#4824
yaacovCR merged 1 commit into
graphql:17.x.xfrom
logaretm:tracing/async-start-emission-timing

Conversation

@logaretm

@logaretm logaretm commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

@yaacovCR This is a minor correction for traceMixed that was introduced in #4670

Once v17 RC was released, I made a round of tests against the observability ecosystem. One thing that I noticed was that OTEL's proposed API for tracing channels in open-telemetry/opentelemetry-js#6387 was mis-parenting async resolvers sometimes.

The reason for this was asyncStart was emitted when the promise was first returned, rather than when the promise settled. Emitting it early meant subscribers that temporarily activate context between asyncStart and asyncEnd could leak that context into overlapping sibling operations.

This did not show up in earlier tests because most subscribers only used start for context creation and asyncEnd for completion. This should not be a breaking change because the terminal end/asyncEnd semantics and result/error payloads remain the same. This is an invisible change for most users, and is only correcting a slight mismatch.

We had to manually implement the async lifecycle in traceMixed here because we needed to preserve the sync/async return paths in resolvers.

I discussed this with @Qard and this should be a more faithful implementation to how tracePromise works under the hood timing-wise.

@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

@logaretm is attempting to deploy a commit to the The GraphQL Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@yaacovCR

Copy link
Copy Markdown
Contributor

@logaretm => agreed, this fix matches the docs.

@yaacovCR yaacovCR merged commit c471d36 into graphql:17.x.x Jun 16, 2026
23 of 24 checks passed
@yaacovCR yaacovCR added the PR: bug fix 🐞 requires increase of "patch" version number label Jun 16, 2026
@logaretm logaretm deleted the tracing/async-start-emission-timing branch June 16, 2026 19:35
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Jun 16, 2026
## v17.0.1 (2026-06-16)

#### Bug Fix 🐞
* [graphql#4824](graphql#4824) fix(diagnostics): emit asyncStart after promise settlement to match native `tracePromise` ([@logaretm](https://github.com/logaretm))

#### Internal 🏠
<details>
<summary> 2 PRs were merged </summary>

* [graphql#4823](graphql#4823) chore(npm): remove obsolete ESM-only package build ([@yaacovCR](https://github.com/yaacovCR))
* [graphql#4825](graphql#4825) chore(release): protect latest release channels ([@yaacovCR](https://github.com/yaacovCR))
</details>

#### Committers: 2
* Abdelrahman Awad([@logaretm](https://github.com/logaretm))
* Yaacov Rydzinski ([@yaacovCR](https://github.com/yaacovCR))
yaacovCR added a commit that referenced this pull request Jun 16, 2026
## v17.0.1 (2026-06-16)

#### Bug Fix 🐞
* [#4824](#4824) fix(diagnostics): emit asyncStart after promise settlement to match native `tracePromise` ([@logaretm](https://github.com/logaretm))

#### Internal 🏠
<details>
<summary> 2 PRs were merged </summary>

* [#4823](#4823) chore(npm): remove obsolete ESM-only package build ([@yaacovCR](https://github.com/yaacovCR))
* [#4825](#4825) chore(release): protect latest release channels ([@yaacovCR](https://github.com/yaacovCR))
</details>

#### Committers: 2
* Abdelrahman Awad([@logaretm](https://github.com/logaretm))
* Yaacov Rydzinski ([@yaacovCR](https://github.com/yaacovCR))
@yaacovCR

Copy link
Copy Markdown
Contributor

@logaretm released in 17.0.1 => thanks for catching this so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: bug fix 🐞 requires increase of "patch" version number

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants