Conversation
`parseEnvelope` treated an item header with `length: 0` as having no
length and tried to read a JSON payload instead. That payload is empty,
so `JSON.parse('')` threw and the whole envelope failed to parse.
This made `handleTunnelRequest` answer 400 for an event that carried an
empty attachment, and made the browser offline transport drop such an
envelope when reading it back from IndexedDB.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
parseEnvelopetreats an item header withlength: 0as if it had no length, because the check isbinaryLength ? readBinary(...) : readJson(). For an empty attachment (for examplescope.addAttachment({ filename: 'log.txt', data: '' })), it then reads the next empty line as JSON.JSON.parse('')throws, so the whole envelope fails to parse.Two places parse envelopes after they have been sent:
handleTunnelRequestanswers400 Invalid envelope, so the event and all its attachments are dropped at the tunnel.shiftreturnsundefinedand the event is lost.The fix checks
binaryLength !== undefined, so a zero-length item reads zero bytes. There are two new tests: aparseEnveloperound trip with an empty attachment, and a tunnel request carrying one. Both fail ondevelop(Unexpected end of JSON input, andfetchis never called) and pass with this change.yarn lint) & (yarn test).I ran the
packages/corevitest suite with and without the change. The only failures are the same 2 environment failures (zoderrrors,typedef) on both.oxfmt --checkis clean on the changed files. I also ranoxlinton them, without the@sentry/eslint-plugin-sdkJS plugin.An AI coding agent (Claude Code, run by breken-ai) found this bug and wrote this change. I checked the red/green tests above before opening the PR.
🤖 Generated with Claude Code