-
Notifications
You must be signed in to change notification settings - Fork 18k
syscall/js: call of Value.Int on undefined on win32 using node.js 10.7.0 #26524
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
The stack trace coming from syscall/js is itself a bit strange when the code does not use syscall/js at all. It seems like the nodejs windows environment is somehow operating on an undefined |
It turns out that (node) This is sufficient to ensure that all constants are present: diff --git a/misc/wasm/wasm_exec.js b/misc/wasm/wasm_exec.js
index 02a753c..71200cb 100644
--- a/misc/wasm/wasm_exec.js
+++ b/misc/wasm/wasm_exec.js
@@ -4,11 +4,21 @@
(() => {
// Map web browser API and Node.js API to a single common API (preferring web standards over Node.js API).
+ const requiredFsConstants = { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1, O_NONBLOCK: -1, O_SYNC: -1 };
const isNodeJS = typeof process !== "undefined";
if (isNodeJS) {
global.require = require;
global.fs = require("fs");
+ Object.entries(requiredFsConstants).forEach(([key, value]) => {
+ if (!(key in global.fs.constants)) {
+ Object.defineProperty(global.fs.constants, key, {
+ value: value,
+ writable: false
+ });
+ }
+ });
+
const nodeCrypto = require("crypto");
global.crypto = {
getRandomValues(b) {
@@ -37,7 +47,7 @@
let outputBuf = "";
global.fs = {
- constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1, O_NONBLOCK: -1, O_SYNC: -1 }, // unused
+ constants: requiredFsConstants, // unused
writeSync(fd, buf) {
outputBuf += decoder.decode(buf);
const nl = outputBuf.lastIndexOf("\n"); |
(The comment that the constants are unused is also manifestly false 😄) |
Change https://golang.org/cl/126600 mentions this issue: |
This commit removes O_NONBLOCK on js/wasm. O_SYNC can't be removed, because it is referenced by the os package, so instead its use returns an error. On Windows, the options O_NONBLOCK and O_SYNC are not available when opening a file with Node.js. This caused the initialization of the syscall package to panic. The simplest solution is to not support these two options on js/wasm at all. Code written for js/wasm is supposed to be portable, so platform-specific options should not be used. Fixes golang#26524. Change-Id: I366aa3cdcfa59dfa9dc513368259f363ca090f00 Reviewed-on: https://go-review.googlesource.com/126600 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
What did you expect to see?
What did you see instead?
Surprisingly, the same wasm binary on the same version of node works correctly on Node on Linux:
The text was updated successfully, but these errors were encountered: