Skip to content

Cannot require() a FIFO #60342

@alxndrsn

Description

@alxndrsn

Version

  • v22.14.0
  • v24.10.0

Platform

6.8.0-85-generic #85~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 19 16:18:59 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

require?

What steps will reproduce the bug?

$ node -e 'const [,f] = process.argv; console.log(require(f))' <(echo 'console.log("hi")')
node:fs:442
    return binding.readFileUtf8(path, stringToFlags(options.flag));
                   ^

Error: ENOENT: no such file or directory, open '/proc/5569/fd/pipe:[27076]'
    at Object.readFileSync (node:fs:442:20)
    at loadSource (node:internal/modules/cjs/loader:1581:17)
    at Object..js (node:internal/modules/cjs/loader:1700:44)
    at Module.load (node:internal/modules/cjs/loader:1289:32)
    at Function._load (node:internal/modules/cjs/loader:1108:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)
    at Module.require (node:internal/modules/cjs/loader:1311:12)
    at require (node:internal/modules/helpers:136:16)
    at [eval]:1:40 {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/proc/5569/fd/pipe:[27076]'
}

Node.js v22.14.0

How often does it reproduce? Is there a required condition?

100%.

What is the expected behavior? Why is that the expected behavior?

Should just require the code and print hi to stdout.

What do you see instead?

$ node -e 'const [,f] = process.argv; console.log(require(f))' <(echo 'console.log("hi")')
node:fs:442
    return binding.readFileUtf8(path, stringToFlags(options.flag));
                   ^

Error: ENOENT: no such file or directory, open '/proc/5569/fd/pipe:[27076]'
    at Object.readFileSync (node:fs:442:20)
    at loadSource (node:internal/modules/cjs/loader:1581:17)
    at Object..js (node:internal/modules/cjs/loader:1700:44)
    at Module.load (node:internal/modules/cjs/loader:1289:32)
    at Function._load (node:internal/modules/cjs/loader:1108:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)
    at Module.require (node:internal/modules/cjs/loader:1311:12)
    at require (node:internal/modules/helpers:136:16)
    at [eval]:1:40 {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/proc/5569/fd/pipe:[27076]'
}

Node.js v22.14.0

Additional information

This works fine:

$ node -e 'const [,f] = process.argv; console.log(require("node:fs").readFileSync(f, "utf8"))' <(echo 'console.log("hi")')
console.log("hi")

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