Skip to content

fix(cloudflare): Wait for span links to be set#21167

Open
JPeer264 wants to merge 1 commit into
developfrom
jp/wait-for-alarm
Open

fix(cloudflare): Wait for span links to be set#21167
JPeer264 wants to merge 1 commit into
developfrom
jp/wait-for-alarm

Conversation

@JPeer264
Copy link
Copy Markdown
Member

This came up in #21101 where the link was not set in time and the tests failed. With this PR we are waiting for the links to be actually set, before the rootspan ends. Retrieving the stored span shouldn't take too long - and the work was also before already executed during the response.

@JPeer264 JPeer264 requested a review from a team as a code owner May 26, 2026 11:12
@JPeer264 JPeer264 requested review from andreiborza and mydea and removed request for a team May 26, 2026 11:12
@JPeer264 JPeer264 self-assigned this May 26, 2026
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ce76d4b. Configure here.

},
(e: unknown) => {
async (e: unknown) => {
await awaitLink();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sync handlers skip link await

Medium Severity

For startNewTrace handlers that return synchronously or throw synchronously, the stored trace link is never awaited and is no longer registered with waitUntil. The span can end before getStoredSpanContext sets sentry.previous_trace, so alarm-style linking can fail for sync alarm implementations.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ce76d4b. Configure here.

Copy link
Copy Markdown
Member

@isaacs isaacs left a comment

Choose a reason for hiding this comment

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

I think the clanker's objection is valid, unless it's impossible to have a link promise and a non-then-able result. Might be good to add a test showing that case, if possible.

If I'm misreading it, happy to update to 👍

},
);
} else {
waitUntil?.(teardown());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If I understand the clanker's objection, seems like there should be a waitIUntil here to handle the linkPromise if the result is not thenable?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants