Closed
Description
I'm noticing an error when using this as a drop-in replacement for the original websockate-json-stream
with ShareDB:
Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
at doWrite (_stream_writable.js:411:19)
at writeOrBuffer (_stream_writable.js:399:5)
at WebSocketJSONStream.Writable.write (_stream_writable.js:299:11)
at Agent.send (/home/curran/repos/sharedb/examples/textarea/node_modules/sharedb/lib/agent.js:165:15)
at Agent._sendOp (/home/curran/repos/sharedb/examples/textarea/node_modules/sharedb/lib/agent.js:181:8)
at OpStream.<anonymous> (/home/curran/repos/sharedb/examples/textarea/node_modules/sharedb/lib/agent.js:103:11)
at OpStream.emit (events.js:197:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at OpStream.Readable.push (_stream_readable.js:224:10)
Emitted 'error' event at:
at errorOrDestroy (internal/streams/destroy.js:98:12)
at onwriteError (_stream_writable.js:430:5)
at onwrite (_stream_writable.js:461:5)
at doWrite (_stream_writable.js:411:11)
at writeOrBuffer (_stream_writable.js:399:5)
[... lines matching original stack trace ...]
at OpStream.emit (events.js:197:13)
This occurs when you load the page, edit text, load the page again, and edit the text again. It feels like the closing of the WebSocket is somehow not cleaned up properly. This error does not happen with the original websockate-json-stream
package.
To reproduce, try changing the dependency to @teamwork/websocket-json-stream
in the ShareDB textarea example https://github.com/share/sharedb/tree/master/examples/textarea
The diff looks something like this:
package.json
- "websocket-json-stream": "^0.0.1",
+ "@teamwork/websocket-json-stream": "^2.0.0",
examples/textarea/server.js
-var WebSocketJSONStream = require('websocket-json-stream');
+var WebSocketJSONStream = require('@teamwork/websocket-json-stream');
Here's a screen capture:
Any ideas what's going on here? Has anyone else observed this error?
Metadata
Metadata
Assignees
Labels
No labels