-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
misc/wasm: Go's WASM shim breaks in Node v19 #56860
Comments
cc @golang/wasm |
I think we can simply drop these shims because the latest Node.js v18 LTS already has them built-in. Our support policy is only to support the active LTS version. |
Oops, not entirely true. Node.js v18 has globalThis.crypto ??= require('crypto'); |
Using the suggested fix would require upgrading our js-wasm builders to LTS 18, so I've opened #57017 to track this effort. Assuming we can get that done I have confirmed locally that the suggested fix works (for both 18 and 19). |
Change https://go.dev/cl/455415 mentions this issue: |
As I understand, the fix suggested in #56860 (comment) (and currently implemented in CL 455415) intentionally drops compatibility with Node 14 ('??=' is too new of a syntax for it; see log). That's fine to do if desired, but submitting that CL will require us to turn off the TryBot part of the current Note that the new Another possible path is to maintain compatibility with Node 18 and 14 only during the transition, and then drop anything only needed for Node 14 afterwards. I think whichever path is easier for the CL author(s) is fine. |
In my testing this fix also drops compatibility for Node 16, the |
It's supported in Node.js v15.0.0 and up https://node.green/#ES2021, I'm assuming the commit is referring to https://nodejs.org/docs/latest-v19.x/api/crypto.html#cryptogetrandomvaluestypedarray which was added in v17.4.0. |
Change https://go.dev/cl/463975 mentions this issue: |
The move to NodeJS 18 allows us to replace the custom crypto functions with the expanded crypto primitives of the NodeJS crypto library. Fixes golang#56860 Change-Id: I8726b4003150f31521f246f613b6976641b9fa69 Reviewed-on: https://go-review.googlesource.com/c/go/+/463975 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Evan Phoenix <evan@phx.io> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Presumably, because the problematic code is still there in the latest commit.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
GOOS=js GOARCH=wasm go build main.go
node $(go env GOPATH)/misc/wasm/wasm_exec_node.js main
What did you expect to see?
Hello world
What did you see instead?
I assume this recent Node change is the cause: nodejs/node#44897. Here's one possible fix:
For further context, this bug was reported to me by a user of esbuild here: evanw/esbuild#2683
The text was updated successfully, but these errors were encountered: