Skip to content
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

wasi incorrectly defined on global #45560

Closed
nomagick opened this issue Nov 21, 2022 · 6 comments · Fixed by #45595
Closed

wasi incorrectly defined on global #45560

nomagick opened this issue Nov 21, 2022 · 6 comments · Fixed by #45595
Labels
repl Issues and PRs related to the REPL subsystem.

Comments

@nomagick
Copy link

nomagick commented Nov 21, 2022

Version

v18.12.1

Platform

Linux - 5.4.190-107.353.amzn2.x86_6

Subsystem

wasi global

What steps will reproduce the bug?

global.wasi

Object.getOwnPropertyNames(global).forEach((k) => {
    const v = Reflect.get(global, k);
    if (isConstructor(v)) {
        NATIVE_CLASS_PROTOTYPES.set(v.prototype, v);
    }
});

Uncaught Error: Cannot find module 'wasi'

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

global.wasi evaluates to undefined;

assert(global.hasOwnProperty('wasi') === false)

What do you see instead?

Uncaught Error: Cannot find module 'wasi' for global.wasi

assert(global.hasOwnProperty('wasi') === true)

Additional information

--experimental-wasi-unstable-preview1 not specified

@cjihrig
Copy link
Contributor

cjihrig commented Nov 21, 2022

I'm not sure exactly what you're reporting here. The wasi module is only available if you start Node with --experimental-wasi-unstable-preview1, and even then it won't be a global.

@nomagick
Copy link
Author

@cjihrig I mean even if I didn't start node with --experimental-wasi-unstable-preview1, it's still defined on global.
It's defined but triggers error when you try to read from it.
So I suppose that's a bug.

@cjihrig
Copy link
Contributor

cjihrig commented Nov 21, 2022

Is this in the REPL only?

@nomagick
Copy link
Author

Oh yes in repl only, sorry.
Not that much of a bug then.

@cjihrig
Copy link
Contributor

cjihrig commented Nov 21, 2022

I'm going to reopen. Even though it's just in the REPL, we should fix this.

@cjihrig cjihrig reopened this Nov 21, 2022
@daeyeon daeyeon added the repl Issues and PRs related to the REPL subsystem. label Nov 21, 2022
@cola119
Copy link
Member

cola119 commented Nov 23, 2022

#39911 (released in v16.10.0) fixed not to load wasi module when the flag is not set, but wasi property is still defined on global.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants