You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix recordPerformance on Cloudflare Workers; add per-call timeout
- await responses().put() on Workers so it flushes inside ctx.waitUntil
(the fire-and-forget put was cancelled when the isolate terminated)
- send sampleRate in the put body to bypass server-side gating
- expose optional timeout for recordPerformance (default 1500ms)
- thread timeout through Resource.put → httpPUT → httpRequest
- extract isCloudflareWorkers detection to common/runtime.ts
- README: document timeout, fix stale factor example, add Workers note
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
sample: 1, // Record 100% of requests (default 0.2)
300
+
statusCode: 200, // HTTP status code (default 200)
301
+
overrideElapsed: 1234, // Custom timing in ms
302
+
timeout: 1500 // Per-call API timeout in ms (default 1500)
301
303
});
302
304
```
303
305
@@ -666,7 +668,7 @@ export default {
666
668
**Workers vs. Express/Lambda — what's different:**
667
669
668
670
- Workers have no mutable response object. Build the outgoing `Response` yourself using values from `result` (`cookieValue`, `targetURL`, `setCookie`) rather than relying on helper methods that mutate a response in place.
669
-
- Use `ctx.waitUntil()` for `recordPerformance()` so the metric call doesn't delay the user's response.
671
+
- Use `ctx.waitUntil()` for `recordPerformance()` so the metric call doesn't delay the user's response. On Workers the SDK awaits the underlying API call internally (so it actually flushes inside `ctx.waitUntil`); the put is capped at 1500ms by default — pass `{ timeout:<ms> }` to tune.
670
672
- Default `mode:'full'` (used above) only needs the public key. Hybrid mode is supported but requires shipping your private key as a Worker secret — only do this if you've assessed the trade-off.
0 commit comments