Skip to content

Remove Sentry instrumentWorkflowWithSentry to resolve workflow timeouts#51

Open
punitarani wants to merge 1 commit intomainfrom
fix/remove-sentry-workflow-instrumentation
Open

Remove Sentry instrumentWorkflowWithSentry to resolve workflow timeouts#51
punitarani wants to merge 1 commit intomainfrom
fix/remove-sentry-workflow-instrumentation

Conversation

@punitarani
Copy link
Owner

Sentry's instrumentWorkflowWithSentry wrapper was interfering with Cloudflare Workers workflow step execution, causing steps to hang and time out despite quick underlying API calls.

Root Cause:

  • Sentry's workflow instrumentation creates additional overhead that doesn't properly serialize/deserialize across workflow hibernation cycles
  • Cloudflare Workflows hibernate and resume, re-executing the run() method
  • This can cause spans to duplicate or timeout when workflow context is lost and restored

Solution:

  • Removed instrumentWorkflowWithSentry from all three workflows:
    • ProcessSeatsAeroSearchWorkflow
    • ProcessFlightAlertsWorkflow
    • CheckFlightAlertsWorkflow
  • Preserved all Sentry monitoring capabilities:
    • captureException() for error tracking (within steps)
    • addBreadcrumb() for execution trails
    • setUser() and setTag() for context
    • workerLogger for structured logging
    • withSentry wrapper at handler level (index.ts)
    • withSentryMonitor for cron check-in tracking (CheckFlightAlertsWorkflow)

Benefits:
✅ Workflows execute without instrumentation overhead ✅ All errors still captured via captureException calls within steps ✅ Breadcrumbs provide execution trail
✅ Cron monitoring still works via withSentryMonitor ✅ HTTP handler monitoring via withSentry in index.ts ✅ No interference with workflow hibernation/resumption

All tests pass (43/43 worker tests)

…imeouts

Sentry's instrumentWorkflowWithSentry wrapper was interfering with Cloudflare
Workers workflow step execution, causing steps to hang and time out despite
quick underlying API calls.

Root Cause:
- Sentry's workflow instrumentation creates additional overhead that doesn't
  properly serialize/deserialize across workflow hibernation cycles
- Cloudflare Workflows hibernate and resume, re-executing the run() method
- This can cause spans to duplicate or timeout when workflow context is lost
  and restored

Solution:
- Removed instrumentWorkflowWithSentry from all three workflows:
  * ProcessSeatsAeroSearchWorkflow
  * ProcessFlightAlertsWorkflow
  * CheckFlightAlertsWorkflow
- Preserved all Sentry monitoring capabilities:
  * captureException() for error tracking (within steps)
  * addBreadcrumb() for execution trails
  * setUser() and setTag() for context
  * workerLogger for structured logging
  * withSentry wrapper at handler level (index.ts)
  * withSentryMonitor for cron check-in tracking (CheckFlightAlertsWorkflow)

Benefits:
✅ Workflows execute without instrumentation overhead
✅ All errors still captured via captureException calls within steps
✅ Breadcrumbs provide execution trail
✅ Cron monitoring still works via withSentryMonitor
✅ HTTP handler monitoring via withSentry in index.ts
✅ No interference with workflow hibernation/resumption

All tests pass (43/43 worker tests)
@vercel
Copy link

vercel bot commented Oct 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
flights-tracker Ready Ready Preview Comment Oct 17, 2025 1:27am

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.

1 participant