Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fs.ReadStream: Pausing, then resuming within the same tick causes "Bad file descriptor" error #535

Closed
papandreou opened this Issue · 3 comments

3 participants

@papandreou

I realize that doing this is kind of silly (and it wasn't what I was doing when I first encountered the bug) – but from the sound of the error message it probably should be fixed.

// Create a fs.ReadStream from any file, big or small.
// Specifying an options hash as the second arg doesn't help.
var readStream = require('fs').createReadStream('shakespeare.txt');

readStream.on('open', function () {
    // If the next two statements are removed or the resume() call is delayed with
    // process.nextTick, it works fine.
    readStream.pause();
    readStream.resume(); // Causes "EBADF, Bad file descriptor" error, ugh!
}).on('error', function (err) {
    console.log("error: " + err);
}).on('data', function () {
    console.log("data");
});

Tested in v0.2.5 and the bleeding edge version.

Best regards,
Papandreou

@isaacs

Verified. This is a bug.

@isaacs

Closed by e1a72f0 Immediate pause/resume race condition

Calling resume() immediately after calling pause() would trigger
a race condition where it would try to read() from a file
descriptor that was already being read from, causing an EBADF

@ry ry closed this
@coolaj86 coolaj86 referenced this issue from a commit
@isaacs isaacs Closes GH-535 Immediate pause/resume race condition
Calling resume() immediately after calling pause() would trigger
a race condition where it would try to read() from a file
descriptor that was already being read from, causing an EBADF
e1a72f0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.