SyntaxError: "[Object Object]" is not valid JSON when parsing event.data
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 279
- PR merge metrics
- No merged PRs in 30d
Description
Description
When handling a message event, the following error occurs:
SyntaxError: "[Object Object]" is not valid JSON
This happens at the line:
const parsed = SuperJSON.parse(event.data);
Details
- File: index.js
- Line: 5924
- Stack: Vue DevTools, Vite, SuperJSON
From the debug panel, event.data is sometimes an object, not a JSON string. When SuperJSON.parse is called on an object, it throws the above error.
Example of problematic data:
event.data = {
payload: '{"json":{"event":{"event":"shutdown"}}}',
source: "proxy->server"
}
Steps to Reproduce
- Trigger a message event where event.data is an object instead of a JSON string.
- The code tries to parse event.data using SuperJSON.parse.
- The error is thrown: "[Object Object]" is not valid JSON.
Expected Behavior
The code should check if event.data is a string before parsing, or handle objects appropriately.
Environment
- OS: macOS m3
- Browser: 137.0.7151.120 (arm64)
- Project: Vue DevTools + Vite
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at index.js line 5924, where event.data is passed to SuperJSON.parse, and inspect the message-event handling around it. Reproduce the case with event.data as the object shown in the issue, then verify that message events with object data no longer throw the reported SyntaxError while string data remains handled correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vite
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100