internal/jsre: pass correct args to setTimeout/setInterval callbacks (#32936)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run

## Description
- Summary: Correct the JS timer callback argument forwarding to match
standard JS semantics.
- What changed: In `internal/jsre/jsre.go`, the callback is now invoked
with only the arguments after the callback and delay.
- Why: Previously, the callback received the function and delay as
parameters, causing unexpected behavior and logic bugs for consumers.
This commit is contained in:
anim001k 2025-10-28 12:34:14 +01:00 committed by GitHub
parent b1db341f7e
commit 59d08c66ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -201,7 +201,7 @@ loop:
if !isFunc {
panic(re.vm.ToValue("js error: timer/timeout callback is not a function"))
}
call(goja.Null(), timer.call.Arguments...)
call(goja.Null(), timer.call.Arguments[2:]...)
_, inreg := registry[timer] // when clearInterval is called from within the callback don't reset it
if timer.interval && inreg {