-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: wrap JSON.parse in try/catch and fix maxAttempts undefined check #4357
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,11 @@ export async function parsePacket(value: IOPacket, options?: ParsePacketOptions) | |
|
|
||
| switch (value.dataType) { | ||
| case "application/json": | ||
| return JSON.parse(value.data, makeSafeReviver(options)); | ||
| try { | ||
| return JSON.parse(value.data, makeSafeReviver(options)); | ||
| } catch { | ||
| return undefined; | ||
| } | ||
| case "application/super+json": | ||
| return superjson.parse(value.data); | ||
|
Comment on lines
39
to
40
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔍 super+json parse path remains unwrapped despite PR claiming both parse functions are fixed The PR description states malformed/truncated payloads caused unhandled rejections in Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| case "text/plain": | ||
|
|
@@ -55,7 +59,11 @@ export async function parsePacketAsJson( | |
|
|
||
| switch (value.dataType) { | ||
| case "application/json": | ||
| return JSON.parse(value.data, makeSafeReviver(options)); | ||
| try { | ||
| return JSON.parse(value.data, makeSafeReviver(options)); | ||
| } catch { | ||
| return undefined; | ||
| } | ||
| case "application/super+json": | ||
| const superJsonResult = superjson.parse(value.data); | ||
|
|
||
|
|
||
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.
🟡 Missing release note entry for a change to a published package
This pull request modifies a published package but does not include the required changeset entry (change in
packages/core/src/v3/apiClient/index.ts:2378), so the fix will not appear in the user-visible release notes.Impact: The bug fixes ship without any changelog/release-note entry and the package version will not be bumped.
Repository changeset rule
AGENTS.md and CONTRIBUTING.md both state that any change to a public package (
packages/*) must include a changeset (pnpm run changeset:add). This PR changespackages/core/src/v3/apiClient/index.tsandpackages/core/src/v3/utils/ioSerialization.tsbut adds no file under.changeset/.Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.