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

setTimeout function not working in GraalJS engine with Maestro #2252

Open
1 task done
JulienLeal opened this issue Jan 16, 2025 · 4 comments
Open
1 task done

setTimeout function not working in GraalJS engine with Maestro #2252

JulienLeal opened this issue Jan 16, 2025 · 4 comments

Comments

@JulienLeal
Copy link

Is there an existing issue for this?

  • I have searched the existing issues and didn't find mine.

Steps to reproduce

When attempting to use the setTimeout function in a JavaScript file (test.js) executed by Maestro using the GraalJS engine, the following error occurs:

TypeError: undefined is not a function
        at <js> :program(test.js:1-3:0-66)

I also tried this example here but I received the same error.

1 - Create a script:

setTimeout(() => {
  console.log("Delayed for 1 second.");
}, 1000);

2 - Create the yaml:

appId: com.myappid.app
jsEngine: graaljs
---
- launchApp
- runScript:
    file: test.js

3- Run the command:
maestro test .maestro/test/test.yaml

I also tried to force the environment:
export MAESTRO_USE_GRAALJS=true

But it seems to didn't affect anything.

Actual results

I received this error:

TypeError: undefined is not a function            
        at <js> :program(test.js:1-3:0-66)       
        at org.graalvm.polyglot.Context.eval(Context.java:399)
        at maestro.js.GraalJsEngine.evaluateScript(GraalJsEngine.kt:73)
        at maestro.js.GraalJsEngine.evaluateScript(GraalJsEngine.kt:24)
        at maestro.orchestra.Orchestra.runScriptCommand(Orchestra.kt:447)
        at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:296)
        at maestro.orchestra.Orchestra.executeCommands(Orchestra.kt:197)
        at maestro.orchestra.Orchestra.runFlow(Orchestra.kt:131)
        at maestro.cli.runner.MaestroCommandRunner.runCommands(MaestroCommandRunner.kt:179)
        at maestro.cli.runner.TestRunner$runSingle$result$1.invoke(TestRunner.kt:62)
        at maestro.cli.runner.TestRunner$runSingle$result$1.invoke(TestRunner.kt:53)
        at maestro.cli.runner.TestRunner.runCatching(TestRunner.kt:160)
        at maestro.cli.runner.TestRunner.runSingle(TestRunner.kt:53)
        at maestro.cli.command.TestCommand.runSingleFlow(TestCommand.kt:352)
        at maestro.cli.command.TestCommand.access$runSingleFlow(TestCommand.kt:63)
        at maestro.cli.command.TestCommand$runShardSuite$2.invoke(TestCommand.kt:326)
        at maestro.cli.command.TestCommand$runShardSuite$2.invoke(TestCommand.kt:297)
        at maestro.cli.session.MaestroSessionManager.newSession(MaestroSessionManager.kt:103)
        at maestro.cli.session.MaestroSessionManager.newSession$default(MaestroSessionManager.kt:53)
        at maestro.cli.command.TestCommand.runShardSuite(TestCommand.kt:297)
        at maestro.cli.command.TestCommand.access$runShardSuite(TestCommand.kt:63)
        at maestro.cli.command.TestCommand$handleSessions$1$results$1$1.invokeSuspend(TestCommand.kt:265)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
        at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:585)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:802)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:706)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:693)

Expected results

I expect no errors and the text Delayed for 1 second. on the console.

About app

The app information on this isn't necessary

About environment

Java version: openjdk 17.0.13 2024-10-15
Ubuntu 22.04.5
x86_64

Logs

Logs
<!-- Replace this line with your logs. *DO NOT* remove the backticks! -->

Maestro version

1.39.7

How did you install Maestro?

install script (https://get.maestro.mobile.dev)

Anything else?

No response

Copy link

linear bot commented Jan 16, 2025

@Fishbowler
Copy link
Contributor

This is (unfortunately) entirely expected.

setTimeout is a node feature, or a browser feature. It's not part of the ECMAScript specification. GraalVM folks are pretty picky on that.

We'd love to upgrade and reconfigure graaljs to support additional Node and JS things, but doing so would cut off some Java versions, and that would upset a lot of folks.

That being said, I bet there's a contribution someone could make that would open up some additional support in the current version - it just needs someone with sufficient motivation to dig into it.

@JulienLeal
Copy link
Author

Hi @Fishbowler I've implemented the setTimeout.

Follow the PR.

@Fishbowler
Copy link
Contributor

Oh wow ♥️

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

2 participants