Workers SDK Issue Reports

← Back to Dashboard

#9489 vite-plugin: `vite dev` does not throw an error when async i/o runs outside a request context

Recommendation:KEEP OPEN
Difficulty:medium
Reasoning:

Confirmed architectural limitation. vite-plugin runs everything in request context (via DO), so workerd can't block module-level async I/O like wrangler dev does. Real impact: OpenAI SDK case.

Suggested Action:

Keep open - valid bug with potential ALS-based solution discussed

Analysis Report

Issue Review: cloudflare/workers-sdk#9489

Summary

vite-plugin does not throw an error when async I/O runs outside a request context (e.g., setTimeout at module level), unlike wrangler dev.

Findings

  • Created: 2025-06-05
  • Updated: 2025-06-17
  • Version: @cloudflare/vite-plugin:1.5.01.21.2 (current)
  • Component: vite-plugin
  • Labels: bug, vite-plugin
  • Comments: 2

Key Evidence

  • Issue is a known architectural challenge: Maintainer @penalosa confirmed this is a known limitation - in Vite, everything runs within a request context (dynamically loaded code orchestrated by a Durable Object), so workerd cannot block async I/O at module level
  • Real-world impact confirmed: @threepointone confirmed this causes actual developer pain - code works in dev but fails at deploy time with hard-to-debug errors. The OpenAI agents SDK encountered this issue
  • No fix has been merged: No PRs reference this issue, and the changelog contains no related fixes
  • No open PRs: No active work to address this issue was found
  • Potential solution discussed: ALS (Async Local Storage) could potentially be used to mimic workerd's blocking behavior

Recommendation

Status: KEEP OPEN

Reasoning: This is a legitimate bug with confirmed real-world impact. The discrepancy between wrangler dev and vite dev causes developers to build applications that work locally but fail at deploy time. The maintainer acknowledged the issue is "quite tricky" to solve but a potential solution (ALS-based mimicking of workerd blocking) was suggested. Given the complexity, this may need to be prioritized.

Action: Keep open as a valid enhancement request. The issue is well-documented with a minimal reproduction and has clear real-world impact.

Notes & Feedback (0)

No notes yet.

Add Note