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

Module exports might be getting wrapped by goja a lot #3707

Open
mstoykov opened this issue Apr 23, 2024 · 0 comments
Open

Module exports might be getting wrapped by goja a lot #3707

mstoykov opened this issue Apr 23, 2024 · 0 comments

Comments

@mstoykov
Copy link
Collaborator

What?

Currently most go modules that export something will just have is a none goja.Value in the modules#Exports. But goja practically only works with goja.Value. So in practically any place where this will be "imported" - it will also be wrapped in one.

This does mean that something simple such as

export default function() { } // to skip error

import k6 from "k6";

console.log(k6.check == k6.check);

will log false .

Some modules such as k6/http has practically fixed this by having a real goja Object instead of expecting that if it had map[string]func()... it will do the right thing.

I hit this while making test for #3706

"setTimeout": e.vu.Runtime().ToValue(e.setTimeout),
"clearTimeout": e.vu.Runtime().ToValue(e.clearTimeout),
"setInterval": e.vu.Runtime().ToValue(e.setInterval),
"clearInterval": e.vu.Runtime().ToValue(e.clearInterval),

@mstoykov mstoykov mentioned this issue Apr 26, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant