-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: network capture tests should fail if we exhaust the body #1395
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@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 |
Size Change: +213 B (+0.02%) Total Size: 1.17 MB
ℹ️ View Unchanged
|
.finally(() => clearTimeout(timeout)) | ||
} catch (e) { | ||
clearTimeout(timeout) | ||
resolve('[SessionReplay] Failed to read body') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a genuine fix for an actual bug, not just a test addition
errors in .text()
are caught in the then
and rejected
but r.clone()
can throw and we wouldn't catch that
so instead we should catch that error, and resolve with something meaningful, that means our captured network request would have this string as its body
and everything else should carry on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not the only way to make this fail though.. it isn't the bug
part of responding to PostHog/posthog#24471 due to the unexpected consequences of #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
Here's the test failing in CI and showing we would have avoided all of the painful impact for folk