share / share/sharedb

When a chunk exceeds the JSON.stringify max length, the stream errors out.

Open
#460 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
6.5k
Forks
456
Avg merge
1d 5h
Merged PRs (30d)
5

Description

Currently, every chunk is stringified before passing the message over. When the chunk is too big for the JSON.stringify method, this will cause the _write function to error out.

https://github.com/share/sharedb/blob/master/lib/stream-socket.js#L60

A workaround for this is to wrap line 60 in a try catch block and instead pass the chunk as it exists before stringifying.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/stream-socket.js at line 60 and trace how _write stringifies each chunk before passing the message onward. Reproduce the failure with a chunk exceeding JSON.stringify's maximum length, then verify that the stream no longer errors and passes the chunk in its existing form when stringification fails.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.