Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

Flush never hits drain condition #376

Open
devshorts opened this issue Jun 2, 2021 · 0 comments
Open

Flush never hits drain condition #376

devshorts opened this issue Jun 2, 2021 · 0 comments

Comments

@devshorts
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant