Skip to content

tty.js -> RangeError [ERR_INVALID_FD]: "fd" must be a positive integer: [object Object] #28590

Description

@ORESoftware

Nodejs version 12

import {ReadStream} from "tty";

const fd = fs.openSync('/dev/tty', 'r+');

console.log({fd});

const strm = new ReadStream({fd});

strm.setRawMode(true);

strm.on('data', (d: any) => {
  console.log({d});
});

I get this error:

tty.js:44
    throw new ERR_INVALID_FD(fd);
    ^

RangeError [ERR_INVALID_FD]: "fd" must be a positive integer: [object Object]
    at new ReadStream (tty.js:44:11)
    at Object.<anonymous> (/Users/alex/codes/ores/bunion/dist/cli.js:322:14)
    at Module._compile (internal/modules/cjs/loader.js:816:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:877:12)
    at internal/main/run_main_module.js:21:11

I can't figure out why. The fd from the open() call is a positive integer.

It's also, of course, a little suboptimal to have [object Object] instead of an inspected object, so at the very least that's a bug/improvement to make.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions