Skip to content

fix(cloudflare): avoid flush lock self-wait - #20719

Merged
isaacs merged 3 commits into
getsentry:developfrom
dmmulroy:fix/cloudflare-workflow-flush-lock
May 9, 2026
Merged

fix(cloudflare): avoid flush lock self-wait#20719
isaacs merged 3 commits into
getsentry:developfrom
dmmulroy:fix/cloudflare-workflow-flush-lock

Conversation

@dmmulroy

@dmmulroydmmulroy commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix workflow final flushing to use the original/bound waitUntil, matching the request wrapper pattern.
  • Pass the workflow execution context into Cloudflare SDK initialization so workflow flushes wait for already-scheduled waitUntil work without scheduling the final flushAndDispose(client) through the same flush-locked context.waitUntil.
  • Add a regression test that models the Cloudflare Vitest worker pool draining waitUntil promises with a timeout.

Test plan

cd packages/cloudflare && yarn test:unit test/workflow.test.ts test/flush.test.ts

Result:

Test Files 2 passed (2)
Tests 14 passed (14)

Note: this PR was written by Pi using GPT-5.5 on medium and directly guided/steered and reviewed by Dillon Mulroy dillon@cloudflare.com.

@dmmulroy
dmmulroy requested a review from a team as a code ownerMay 7, 2026 22:44
@dmmulroy
dmmulroyforce-pushed the fix/cloudflare-workflow-flush-lock branch from ea9e935 to faad412CompareMay 7, 2026 23:03
Comment threadpackages/cloudflare/src/workflows.ts
@dmmulroy
dmmulroyforce-pushed the fix/cloudflare-workflow-flush-lock branch from faad412 to 25de807CompareMay 7, 2026 23:24

@cursorcursorBot left a comment

Copy link
Copy Markdown

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 25de807. Configure here.

Comment threadpackages/cloudflare/src/workflows.ts
Co-Authored-By: GPT-5.5 <noreply@anthropic.com>
@dmmulroy
dmmulroyforce-pushed the fix/cloudflare-workflow-flush-lock branch from 25de807 to 8c09c10CompareMay 7, 2026 23:39

@isaacsisaacs left a comment

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.

LGTM, thanks!

@isaacs
isaacs merged commit a3d1202 into getsentry:developMay 9, 2026
65 of 67 checks passed
andreiborza pushed a commit that referenced this pull request May 11, 2026
This PR adds the external contributor to the CHANGELOG.md file, so that
they are credited for their contribution. See #20719
Co-authored-by: isaacs <9287+isaacs@users.noreply.github.com>
Sign up for freeto 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

@dmmulroy@isaacs