-
Notifications
You must be signed in to change notification settings - Fork 18k
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
syscall/js: panic in os.Getpid() when called from wasm in a browser #34627
Comments
os.Getpid() will panic on wasm in browsers (but not in node). Issue: golang/go#34627
os.Getpid() will panic on wasm in browsers (but not in node). Issue: golang/go#34627
fix: work around golang/go#34627
Correct. The syscall package is not aware of whether it is being called inside a browser or node. Hence it crashes when you try to access the @neelance - Do you think it makes sense to add a package level doc mentioning that any function which does not have the corresponding functionality in the target environment will panic ? I think intentional panics should be documented somewhere. |
If these panics are intentional, they should be an explicit However, I strongly disagree that they should panic. |
+1 to return some form of error ... I just found out this broke github.com/golang/glog in wasm :\ |
Change https://golang.org/cl/199357 mentions this issue: |
Change https://golang.org/cl/199698 mentions this issue: |
QQ: did the fix made into 1.13.3 ? (sorry, the release notes don't mention it, but I'm not sure how the process works) |
It did not. Patch releases are only for security fixes and serious regressions. You will have to wait for 1.14, or alternatively use tip. |
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?
Tried to use
os.Getpid()
from WASM. Gist: https://gist.github.com/Stebalien/4c478e71b0264f9dd66dab9676770511What did you expect to see?
Either the PID or a faked PID when not applicable (e.g., 1).
What did you see instead?
A panic:
The syscall/js package assumes that all wasm instances have "fs" and "process" globals available.
The text was updated successfully, but these errors were encountered: