It seems that flush should be checking the result of process.stdout.write to see if it was already flushed or not. For example ``` async function flush() { const p = new Promise(resolve => process.stdout.once('drain', () => resolve())); const flushed = process.stdout.write(''); if(flushed) { return Promise.resolve() } return p; } ``` If it's NOT flushed, then wait for drain. Otherwise because it's already drained the event never seems to fire so the other promise.race always wins
It seems that flush should be checking the result of process.stdout.write to see if it was already flushed or not. For example
If it's NOT flushed, then wait for drain. Otherwise because it's already drained the event never seems to fire so the other promise.race always wins