dop251 / goja

ECMAScript/JavaScript engine in pure Go
MIT License
5.57k stars 376 forks source link

if i want to let users do js on my server like cloudflare workers, is it possible to use your repo to do so? #575

Closed sprappcom closed 5 months ago

sprappcom commented 5 months ago
  1. what caveats do i have to look out for?
  2. any suggestions / examples on how to get it done?
  3. do u think v8 binding is better? i have issues with high concurrent connections stress test that crashes v8 stuff. goja crashed too but i put into goja pool and it's "stable" now.
        runtime := hs.runtimePool.Get().(*goja.Runtime)
        defer hs.runtimePool.Put(runtime)
func (hs *httpServer) newRuntime() *goja.Runtime {
        vm := goja.New()
        _, err := vm.RunString(hs.scriptData)
        if err != nil {
                log.Fatalf("Failed to initialize Goja runtime: %s", err)
        }
        return vm
}

thx by the way for this repo.

dop251 commented 5 months ago

I'm not really sure what the question is, sorry.