-
Notifications
You must be signed in to change notification settings - Fork 18k
wasm: Handling EPIPE from WASM seems impossible? #59099
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
Comments
(attn @golang/wasm) |
In discussion on #11845 we decided that the right approach was that if we get an Now, it happens that because the build tag for os/file_unix.go includes js-wasm, that behavior applies to js-wasm as well (it's in the function |
This issue affects many users of TeamCity and Jenkins that use esbuild (that uses GO). Hopefully it does not languish in the backlog for too long. |
Still languishing? 😁
From |
- evanw/esbuild#1662 - golang/go#59099 confusing output from esbuild-wasm even after supposed end of process
Change https://go.dev/cl/614935 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I'm the author of esbuild, a JavaScript build tool written in Go. One way to run esbuild is to use node's WebAssembly implementation with the
.wasm
file that Go generates. The esbuild library launches a child process that runs the.wasm
file and communicates with the parent process over stdin+stdout. When the parent process exits, the child process is supposed to detect that stdout is no longer writable and exit. However, I'm seeing something like this instead:Click to expand Go's verbose fatal panic log message...
What did you expect to see?
I expect
os.Stdout.Write
to returnEPIPE
if writing toos.Stdout
fails withEPIPE
.What did you see instead?
It seems like if
os.Stdout
fails withEPIPE
, Go's standard library throws an error that as far as I can tell is impossible to catch. Things I tried:I tried adding a deferred call to
recover()
, but it's never called.I tried calling
signal.Ignore(syscall.SIGPIPE)
but there is noSIGPIPE
signal when building for WASM.I dug deeper and discovered that Go's implementation for
SIGPIPE
callsthrow
which then callsfatalthrow
which I assume is impossible to catch. I'm assuming this is a bug with Go because I don't understand why it would be desirable for a Go program to unconditionally crash when encountering a normal error condition such as (in this case) the parent process exiting.I just need some way to make Go not do this, but I don't care exactly how. From my perspective I don't want to deal with
SIGPIPE
at all because it's a nuisance so ideallyos.Stdout.Write
would just returnEPIPE
. But I'm also willing to callsignal.Ignore(syscall.SIGPIPE)
beforeos.Stdout.Write
if that's the desired solution instead.The text was updated successfully, but these errors were encountered: