diff --git a/runtime.go b/runtime.go index a8a3ecc9..f4e2e1d1 100644 --- a/runtime.go +++ b/runtime.go @@ -203,6 +203,7 @@ type Runtime struct { limiter *rate.Limiter limiterTicksLeft int + limiterWaitCount uint64 ticks uint64 tickMetricTrackingEnabled bool @@ -213,6 +214,10 @@ func (self *Runtime) Ticks() uint64 { return self.ticks } +func (self *Runtime) LimiterWaitCount() uint64 { + return self.limiterWaitCount +} + // SetStackTraceLimit sets an upper limit to the number of stack frames that // goja will use when formatting an error's stack trace. By default, the limit // is 10. This is consistent with V8 and SpiderMonkey. diff --git a/vm.go b/vm.go index cc974c78..49871cab 100644 --- a/vm.go +++ b/vm.go @@ -617,6 +617,7 @@ func (vm *vm) run() { ctx = context.Background() } + vm.r.limiterWaitCount++ if waitErr := vm.r.limiter.WaitN(ctx, vm.r.limiterTicksLeft); waitErr != nil { if vm.r.vm.ctx == nil { panic(waitErr)