-
Notifications
You must be signed in to change notification settings - Fork 61
Closed
Milestone
Description
The following code works:
await vm.evalAsync(`
puts "step 1"
JS.global.fetch("https://example.com").await
puts "step 3"
`);
However, the following code fails with the error
RbError: /usr/local/lib/ruby/site_ruby/3.2.0/js.rb:86:in `await': JS::Object#await can be called only from RubyVM#evalAsync JS API`
const result = await vm.evalAsync(`
def foo()
puts "step 1"
JS.global.fetch("https://example.com").await
puts "step 3"
end
`)
await result.call("foo")
Is there a way to define a function, call it later (from JS), and still use async operations?
In my use case, I'm precompiling framework routes, and executing them with (different) requests.
Metadata
Metadata
Assignees
Labels
No labels