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

Support for V8 JavaScript Engine? #4056

Open
LukeKeywalker opened this issue Apr 17, 2024 · 2 comments
Open

Support for V8 JavaScript Engine? #4056

LukeKeywalker opened this issue Apr 17, 2024 · 2 comments

Comments

@LukeKeywalker
Copy link

I try to use FS2 from inside Unreal engine via Unreal.js plugin, which essentially is a wrapper around V8 JavaScript engine, but I get into undefined required script 'perf_hooks', and missing setTimeout method.

LogJavascript: Warning: Undefined required script 'perf_hooks'
LogJavascript: Error: file:///c:/Users/Lukasz.Michniewicz/projects/UnrealScalaJS/Content/Scripts/main.js:480: ReferenceError: setTimeout is not defined
LogJavascript: Error:     at file:///c:/Users/Lukasz.Michniewicz/projects/UnrealScalaJS/Content/Scripts/main.js:480:327
LogJavascript: Error:     at H.d (file:///c:/Users/Lukasz.Michniewicz/projects/UnrealScalaJS/Content/Scripts/main.js:421:173)
LogJavascript: Error:     at Pz.wk (file:///c:/Users/Lukasz.Michniewicz/projects/UnrealScalaJS/Content/Scripts/main.js:481:37)
LogJavascript: Error:     at Ic.wk (file:///c:/Users/Lukasz.Michniewicz/projects/UnrealScalaJS/Content/Scripts/main.js:434:364)
LogJavascript: Error:     at Ho (file:///c:/Users/Lukasz.Michniewicz/projects/UnrealScalaJS/Content/Scripts/main.js:204:233)
LogJavascript: Error:     at jn (file:///c:/Users/Lukasz.Michniewicz/projects/UnrealScalaJS/Content/Scripts/main.js:203:288)
LogJavascript: Error:     at Wm (file:///c:/Users/Lukasz.Michniewicz/projects/UnrealScalaJS/Content/Scripts/main.js:192:252)
LogJavascript: Error:     at Vm.sayHello (file:///c:/Users/Lukasz.Michniewicz/projects/UnrealScalaJS/Content/Scripts/main.js:192:308)
LogJavascript: Error:     at file:///../../../../../../Users/Lukasz.Michniewicz/projects/UnrealScalaJS/Content/Scripts/on-start.js:5:14
LogJavascript: Error:     at file:///../../../../../../Users/Lukasz.Michniewicz/projects/UnrealScalaJS/Content/Scripts/on-start.js:7:3

As far as I know this error occurs in non-browser environments like Node.js, and I guess V8 falls into this category as well. Is there any way of compiling code using FS2 which does not use setTimeout internally?

@LukeKeywalker LukeKeywalker changed the title Support for V8 Javascript Engine? Support for V8 JavaScript Engine? Apr 17, 2024
@armanbilge armanbilge transferred this issue from typelevel/fs2 Apr 17, 2024
@armanbilge
Copy link
Member

As far as I know this error occurs in non-browser environments like Node.js

Hm, that can't be right. We test both FS2 and Cats Effect on Node.js in CI :)

Is there any way of compiling code using FS2 which does not use setTimeout internally?

setTimeout is used for implementing IO.sleep. Without an alternative API that we could use for this, it's impossible to have a fully functional runtime. What kind of program are you hoping to run?


BTW, I have made changes before to better support V8. I believe it does support setTimeout.

@djspiewak
Copy link
Member

I think the bigger problem you might run into will be the lack of setImmediate. I'm not sure if bare V8 has that, and if it doesn't, it's certainly not going to support any of the polyfill shenanigans we do to replace it, so you're probably going to end up with a lot of setTimeout(0, ...). That would be an interesting thing to look at as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants