Skip to content

Cloudflare Workflow reports runtime cancellation after successful run during Sentry teardown #23111

Description

@matthew-gizmo

Environment

  • @sentry/cloudflare 10.69.0
  • Cloudflare Workflows

Problem

The Workflow completes successfully, but the Workers runtime subsequently reports:

The Workers runtime canceled this request because it detected that your Worker code had hung and would never generate a response.

Evidence

For one staging invocation:

  • workflow_complete: 2026-08-06T15:02:11.150Z
  • finalization_outcome: 2026-08-06T15:02:11.572Z
  • workflow_wrapper_outcome with final status SUCCESS: 2026-08-06T15:02:11.587Z
  • Workers runtime cancellation: 2026-08-06T15:02:13.572Z

The cancellation occurred approximately 1.985 seconds after the successful wrapper outcome, matching the 2-second Sentry flush timeout. Application work and finalization had completed; the cancellation followed Sentry teardown scheduled through waitUntil.

Relationship to #23005 and #23017

Issue #23005 identified a Workflow-instance reuse deadlock caused by capturing Sentry instrumented waitUntil. PR #23017 fixed that by using getOriginalWaitUntil(context). The post-success cancellation still occurs.

We are testing a local mitigation that awaits flushAndDispose(client) before the Workflow run() returns, instead of scheduling Sentry teardown through waitUntil.

Expected behavior

A successfully completed Workflow should not produce a later Workers runtime cancellation, while Sentry teardown remains safely flushed and disposed.

Please investigate whether Workflow instrumentation should await teardown, use a different lifecycle mechanism, or otherwise prevent Sentry teardown from being treated as hung by the Workers runtime.

Related: #23005, #23017

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions