Commit fbbdc9e
fix(serverless-hono): withWaitUntil must not destroy global state when context has no waitUntil (#1214)
* fix(serverless-hono): withWaitUntil must not destroy global state when context has no waitUntil
Two bugs in withWaitUntil:
1. The else branch unconditionally set ___voltagent_wait_until = undefined
even when the global already held a value from an outer scope. This
silently killed background tasks (observability, logging) in middleware
chains where an inner handler passed {} as context.
2. Errors thrown by context.waitUntil (e.g. DataCloneError in Cloudflare
Workers) propagated to callers. The test suite expected them to be
swallowed; wrapping the call in try/catch aligns implementation with
that contract.
Fix:
- Remove the else branch entirely. When context has no waitUntil the
global is left untouched.
- Wrap the bound waitUntil call in try/catch to swallow errors.
- Simplify the cleanup function to always restore previousWaitUntil
unconditionally (no currentWaitUntil guard needed).
All 11 tests in wait-until-wrapper.spec.ts now pass.
Fixes #1203
* chore: add changeset
---------
Co-authored-by: octo-patch <octo-patch@github.com>
Co-authored-by: Omer Aplak <omeraplak@gmail.com>1 parent 71c9f84 commit fbbdc9e
2 files changed
Lines changed: 18 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 13 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
41 | 46 | | |
| 47 | + | |
| 48 | + | |
42 | 49 | | |
43 | | - | |
| 50 | + | |
44 | 51 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
0 commit comments