Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

ReadStream#resume() throws TypeError: Bad argument if called immediately #687

Closed
slaskis opened this issue Feb 17, 2011 · 5 comments
Closed

Comments

@slaskis
Copy link

slaskis commented Feb 17, 2011

Here's a small reproducible example (in 0.4.0):

var tmp = require("fs").createReadStream("/dev/random");
tmp.pause() // not required, it throws even without pausing
tmp.resume()

With a process.nextTick it works:

var tmp = require("fs").createReadStream("/dev/random");
tmp.pause()
process.nextTick(function(){ tmp.resume() })
@isaacs
Copy link

isaacs commented Feb 18, 2011

Fix https://gist.github.com/833106

@slaskis
Copy link
Author

slaskis commented Feb 18, 2011

Actually after some more testing it seems that a process.nextTick() is not always enough. However this seems to help:

tmp.on("open",function(){process.nextTick(function(){tmp.resume()})})

@isaacs
Copy link

isaacs commented Feb 18, 2011

The important thing is that the resume() will throw if it comes before the "open" event. Attached patch fixes it.

@isaacs
Copy link

isaacs commented Feb 20, 2011

Closed by 8b9dbda Don't read fs read stream if not open

@slaskis
Copy link
Author

slaskis commented Feb 20, 2011

Great, thanks!

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants