diff --git a/pkg/filters/goja/goja.go b/pkg/filters/goja/goja.go index 3259bce..ff4f05c 100644 --- a/pkg/filters/goja/goja.go +++ b/pkg/filters/goja/goja.go @@ -133,9 +133,14 @@ func FilterInstGoJa(gl core.Params) (core.FilterInstance, error) { } if result != nil { if _, ok := result.Export().(*goja.Promise); ok { - vm.Set("__internal_resolve", func(goja.Value) { stop <- nil }) - vm.Set("__internal_reject", func(reason goja.Value) { stop <- errors.New(reason.String()) }) - vm.Set("__internal_promise", result) + if err := errors.Join( + vm.Set("__internal_resolve", func(goja.Value) { stop <- nil }), + vm.Set("__internal_reject", func(reason goja.Value) { stop <- errors.New(reason.String()) }), + vm.Set("__internal_promise", result), + ); err != nil { + stop <- err + return + } _, err := vm.RunString(`__internal_promise.then(__internal_resolve).catch(__internal_reject)`) if err != nil { stop <- err diff --git a/pkg/server.go b/pkg/server.go index 0b2a78c..df24f03 100644 --- a/pkg/server.go +++ b/pkg/server.go @@ -67,7 +67,7 @@ func WithEvent(event subscribe.Subscriber) ServerOption { } } -func WithMetaCache(cache kv.KV, ttl time.Duration, refresh time.Duration, refreshConcurrent int) ServerOption { +func WithMetaCache(cache kv.KV, ttl, refresh time.Duration, refreshConcurrent int) ServerOption { return func(c *serverConfig) { c.cacheMeta = cache c.cacheMetaTTL = ttl