dop251 / goja_nodejs

Nodejs compatibility library for Goja
MIT License
336 stars 81 forks source link

EventLoop: runtime management #67

Closed bubbajoe closed 1 year ago

bubbajoe commented 1 year ago

Issue

I am creating a function fetch for creating http requests. But I need access to the runtime to create a Promise object.

Any ideas on how I can deal with this? I tried using the RunOnLoop function inside of the fetch function, but it was never scheduled.

Which makes since since the fetch function needs to finish executing before the runtime can schedule anything else.

Potential Fix

Add GetRuntime() *Runtime, which panics when the event loop is not running?