STDIN breaks after refreshing piped executables
See original GitHub issuenodemon -v: ^1.19.4node -v: v13.3.0- Operating system/terminal environment: Windows/Git Bash
- Using Docker? What image:
- Command you ran: nodemon -e js --exec “node …\external\secret.js | node server.js”
Expected behaviour
Run consistently, at least always give me an error.
Actual behaviour
Somehow, I get trapped getting errors if my code produces an error in a refresh. Sometimes, not consistent with any other events that I can tell, I keep getting the error below every time I try and refresh. I can open a new shell terminal, I can close/reopen all shell terminals on the system, but every time I try and run the command it spits out this error. If I wait for another 5-10min, it seems to just go away on its own.
I’m getting an error from node’s built-in fs module: internal/fs/utils.js:227 throw err; Error: EOF: end of file, read errno: -4095, syscall: ‘read’, code: ‘EOF’
Steps to reproduce
Run a express server that blocks on being initialized from data from stdin, then add a throw at the beginning, save/refresh through nodemon, remove the throw and attempt to run again. Like I said this seems to be entirely unpredictable; so sometimes I’ll have to add/remove the throw a couple times or restart my shell.
// Source file
const objectToWrite = { somedata:'someval' }
process.stdout.write(JSON.stringify(objectToWrite));
process.stdout.end('\n');
// I've messed around with various STDIO implementations
// and it doesn't seem to have any affect the error.
// Receiving file
const fs = require('fs')
let envTmp = fs.readFileSync(0).toString();
// breaks on fs utils here ^
envTmp = JSON.parse(envTmp);
Dump Text
[nodemon] 1.19.4
[nodemon] to restart at any time, enter rs
[nodemon] watching dir(s): .
[nodemon] watching extensions: js
node: v13.3.0 nodemon: 1.19.4 command: C:\Program Files\nodejs\node.exe bin\nodemon.js -e js --exec node …\secret.js | node server.js --dump OS: win32 x64
{
run: false,
required: false,
timeout: 1000,
options: {
exec: 'node ..\\secret.js | node server.js',
dump: true,
ignore: [
'**/.git/**',
'**/.nyc_output/**',
'**/.sass-cache/**',
'**/bower_components/**',
'**/coverage/**',
'**/node_modules/**',
re: /.*.*\/\.git\/.*.*|.*.*\/\.nyc_output\/.*.*|.*.*\/\.sass\-cache\/.*.*|.*.*\/bower_components\/.*.*|.*.*\/coverage\/.*.*|.*.*\/node_modules\/.*.*/
],
watch: [ '*.*', re: /.*\..*/ ],
ignoreRoot: [
'**/.git/**',
'**/.nyc_output/**',
'**/.sass-cache/**',
'**/bower_components/**',
'**/coverage/**',
'**/node_modules/**'
],
restartable: 'rs',
colours: true,
execMap: { py: 'python', rb: 'ruby', ts: 'ts-node' },
stdin: true,
runOnChangeOnly: false,
verbose: false,
signal: 'SIGUSR2',
stdout: true,
watchOptions: {},
execOptions: {
script: null,
exec: 'node ..\\secret.js | node server.js',
args: [],
scriptPosition: null,
nodeArgs: undefined,
execArgs: [],
ext: 'js',
env: {}
},
monitor: [
'*.*',
'!**/.git/**',
'!**/.nyc_output/**',
'!**/.sass-cache/**',
'!**/bower_components/**',
'!**/coverage/**',
'!**/node_modules/**'
]
},
load: [Function (anonymous)],
reset: [Function: reset],
lastStarted: 0,
loaded: [],
watchInterval: null,
signal: 'SIGUSR2',
command: {
raw: {
executable: 'node ..\\secret.js | node server.js',
args: []
},
string: 'node ..\\secret.js | node server.js'
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)

Top Related StackOverflow Question
I just refactored my code to wrap the whole thing in a
.then()to use the normalprocess.stdinand now it doesn’t seem to have any issues.Does nodemon try and detect if
stdinis being used? Maybe it just missedfs.readFileSync(0)?Can you provide a pared down code sample to run? Otherwise I can’t reproduce.