Skip to content

Commit e6c8019

Browse files
fix(devserver): use readline instead of reading from raw stdin (#2099)
1 parent 66a85a6 commit e6c8019

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

js/private/js_run_devserver.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as fs from 'node:fs'
44
import * as os from 'node:os'
55
import * as child_process from 'node:child_process'
66
import * as crypto from 'node:crypto'
7+
import * as readline from 'node:readline'
78

89
// Globals
910
const RUNFILES_ROOT = path.join(
@@ -452,10 +453,11 @@ async function main(args, sandbox) {
452453
})
453454

454455
// Process stdin data in order using a promise chain.
455-
let syncing = Promise.resolve()
456-
process.stdin.on('data', async (chunk) => {
457-
return (syncing = syncing.then(() => processChunk(chunk)))
458-
})
456+
let syncing = Promise.resolve();
457+
const rl = readline.createInterface({ input: process.stdin });
458+
rl.on('line', (line) => {
459+
syncing = syncing.then(() => processChunk(line));
460+
});
459461

460462
async function processChunk(chunk) {
461463
try {

0 commit comments

Comments
 (0)