Skip to content
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

The stream loses data #139

Open
DmitryMyadzelets opened this issue Feb 18, 2018 · 4 comments
Open

The stream loses data #139

DmitryMyadzelets opened this issue Feb 18, 2018 · 4 comments

Comments

@DmitryMyadzelets
Copy link

DmitryMyadzelets commented Feb 18, 2018

In this use case we send a file. All data are lost if the file is small, or received partially if the file is big.

How to reproduce:

const fs = require('fs')
const reader = fs.ReadStream('index.js')
const writer = fs.WriteStream('out')
const socket = require('websocket-stream')('ws://echo.websocket.org')

reader.pipe(socket).pipe(writer)

// Now compare the size of the input and output files

Node.js v8.6.0

@DmitryMyadzelets
Copy link
Author

DmitryMyadzelets commented Feb 19, 2018

Have found that the stream intentionally throws away any data unless the socket is connected. What is a rationale behind such decision?

@mcollina
Copy link
Collaborator

This module is very old, and there might not be a good rationale behind some of the code. If you want to help maintaining this you are welcome to propose a change.

@DmitryMyadzelets
Copy link
Author

With modern Node.js making a stream over a WebSocket (ws module) seems quite simple for a trivial use case.

May a complete refactoring be considered?

@mcollina
Copy link
Collaborator

mcollina commented Mar 2, 2018

As long as the API stays similar and the tests passes, I see no problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants