Commit f7036c0
committed
fix(core): consume response body in _flush() and _capture() to prevent Cloudflare Workers warnings
`_flush()` and the single-event `_capture()` path both call
`fetchWithRetry()` but discard the returned response without reading
the body. In runtimes like Cloudflare Workers that enforce response
body consumption, this causes cross-request promise resolution warnings
and may silently cancel post-flush error handling continuations.
Consume the response body with `res.text().catch(() => {})` at both
call sites on the success path. Also consume the response body held by
`PostHogFetchHttpError` on error paths (e.g. 413 batch-size reduction)
to prevent the same leak on failed requests.
The `fetchWithRetry()` return type is preserved so callers that need
the response (e.g. surveys API) can still read it.
Fixes #31731 parent dc59f94 commit f7036c0
1 file changed
+19
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
964 | 964 | | |
965 | 965 | | |
966 | 966 | | |
967 | | - | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
968 | 972 | | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
969 | 977 | | |
970 | 978 | | |
971 | 979 | | |
| |||
1139 | 1147 | | |
1140 | 1148 | | |
1141 | 1149 | | |
1142 | | - | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
1143 | 1155 | | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
1144 | 1161 | | |
1145 | 1162 | | |
1146 | 1163 | | |
| |||
0 commit comments