PostHog / posthog-js

Send usage data from your web app or site to PostHog, with autocapture.
https://posthog.com/docs/libraries/js
Other
278 stars 114 forks source link

fix: network capture tests should fail if we exhaust the body #1395

Closed pauldambra closed 1 month ago

pauldambra commented 1 month ago

part of responding to https://github.com/PostHog/posthog/issues/24471 due to the unexpected consequences of https://github.com/PostHog/posthog-js/pull/1351

it is very hard to test for all unexpected consequences of changes to code 🙈

but we do at least now know for sure that that we cannot rely on request/response objects being readable and that we should not read them and then pass them on

Screenshot 2024-08-30 at 10 03 11

Here's the test failing in CI and showing we would have avoided all of the painful impact for folk

  1 failing
  1) Session recording
       network capture - when fetch wrapper is not badly behaved
         it sends network payloads:
     TypeError: The following error originated from your test code, not from Cypress. It was caused by an unhandled promise rejection.
  > Failed to execute 'fetch' on 'Window': Cannot construct a Request with a Request object that has already been used.
vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗ī¸Ž

Name Status Preview Updated (UTC)
posthog-js ✅ Ready (Inspect) Visit Preview Aug 30, 2024 11:22am
pauldambra commented 1 month ago

@daibhin @neilkakkar just a heads up on this in case you spot anything, but don't worry too much, it's very much a spike at the moment

github-actions[bot] commented 1 month ago

Size Change: +213 B (+0.02%)

Total Size: 1.17 MB

Filename Size Change
dist/array.full.js 335 kB +71 B (+0.02%)
dist/recorder-v2.js 110 kB +71 B (+0.06%)
dist/recorder.js 110 kB +71 B (+0.06%)
ℹī¸ View Unchanged | Filename | Size | | :--- | :---: | | `dist/array.js` | 156 kB | | `dist/exception-autocapture.js` | 10.4 kB | | `dist/main.js` | 157 kB | | `dist/module.js` | 156 kB | | `dist/surveys-preview.js` | 59.8 kB | | `dist/surveys.js` | 66 kB | | `dist/tracing-headers.js` | 8.26 kB | | `dist/web-vitals.js` | 5.79 kB |

compressed-size-action