-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Description
- Version: since dec 2011, a936768#diff-9a205ef7ee967ee32efee02e58b3482dR1342
- Platform: all
- Subsystem: fs, stream
process.stdout and process.stderr are not implementing Stream 2 or 3 if they are redirected to a file. They are a SyncWriteStream:
node/lib/internal/process/stdio.js
Line 149 in dc72779
| stream = new fs.SyncWriteStream(fd, { autoClose: false }); |
This is were the choice is made.:
node/lib/internal/process/stdio.js
Lines 147 to 151 in dc72779
| case 'FILE': | |
| const fs = require('internal/fs'); | |
| stream = new fs.SyncWriteStream(fd, { autoClose: false }); | |
| stream._type = 'fs'; | |
| break; |
I know too little of the stdio sync/async situation to identify what should be preferred change. Ideally process.stdout and process.stderr should come from the streams implementations, but I might be wrong.
What are the implications of doing so? Why is this needed in the first place?
As an example, can we use net.Socket instead
node/lib/internal/process/stdio.js
Lines 156 to 160 in dc72779
| stream = new net.Socket({ | |
| fd: fd, | |
| readable: false, | |
| writable: true | |
| }); |
Issues related:
sindresorhus/is-stream#5
pinojs/pino#85
pinojs/pino#86
cc @jasnell @Fishrock123 @jsumners @catdad @sindresorhus @nodejs/streams