-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unexpected behavior: after awaiting esbuild.build, stdout hasn't received all output #1869
Comments
No, it's not known behavior. I could potentially try to figure out why it's happening if you're able to provide a way to reproduce the issue. I believe the data written to stdout happens in a single Line 1093 in 8244508
|
In looking at the notes for node.js on I think what's happening is the code is running under one of these cases where Which sounds very similar to what happened here: nodejs/node#7743 I don't know what (if any) the remediation steps are. My first instinct was trying to attach some events to stdout to determine when the write finishes, but I don't know if that's feasible. |
if there is no remediation step code-wise, maybe we put some kind of blurb in the docs around the mode where we write to |
when in doubt: |
That doesn't solve the problem. This issue isn't about await esbuild.build(...) finishes, the expectation of the API is that all of the content has finished writing to |
await new Promise(resolve => { esbuild.build( ... ); process.stdout.once('drain', () => resolve()); }); I have no way of testing at the moment, so let me know if that's totally unhelpful |
Heh, sorry I wasn't sure. Lack of tone on the internet strikes again. :)
That looks like it could work. I forget the behavior of |
If I've understood correctly, the |
I'm going to mark this as |
Yeah I think that's fair. It's technically actionable I think but it's not easy to setup. It would require having a hosted virtual instance with extremely low i/o, running windows as an OS. I'm glad this is being labeled rather than closed. It's a pretty bad issue when encountered because there's no error, and nothing obviously wrong. Keeping it open will make it easier to find should others search for this later. |
Just to quench my curiosity, how did you work around this? |
I had code that basically looked like this: await esbuild.build(cfg)
process.exit() I worked around this by simply removing await esbuild.build(cfg)
doMoreStuffThatDependsOnTheBuildBeingComplete() |
ah I see. That's a friendly solution. Otherwise, I guess you could use the shell to spawn a new node instance when that one finishes, should you need to do more stuff. |
I'm going to close this issue since it has been unactionable for a long time without any progress. If someone is willing to investigate this and discover the cause (and maybe even propose a fix), then we can revive this issue. |
I'm integrating esbuild into a build process on our backend, and there was something peculiar I noticed.
After
await
ing theesbuild
completion,stdout
may not have all of the output:mybuild.js:
It wasn't what I expected. I know
process.exit()
is an anti-pattern, but I'm demonstrating that if I just exit the script after thatawait
, I would have though everything would be instdout
by then. It's resulting in truncation when I do:node mybuild.js > out.js
Is this a bug, or a known behavior?
The text was updated successfully, but these errors were encountered: