From 94a85f41620c26f4a9b2ac8b92fd05ccd00902ef Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Sun, 21 Sep 2025 18:58:28 +0800 Subject: [PATCH] console: fix some goja-related crashes/errors in the bridge #21050 (#1522) --- console/bridge.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/console/bridge.go b/console/bridge.go index 6b3e6f6b07..b6f67e0483 100644 --- a/console/bridge.go +++ b/console/bridge.go @@ -49,6 +49,9 @@ func newBridge(client *rpc.Client, prompter UserPrompter, printer io.Writer) *br // Sleep will block the console for the specified number of seconds. func (b *bridge) Sleep(call jsre.Call) (goja.Value, error) { + if nArgs := len(call.Arguments); nArgs < 1 { + return nil, errors.New("usage: sleep()") + } if !isNumber(call.Argument(0)) { return nil, errors.New("usage: sleep()") } @@ -76,7 +79,7 @@ func (b *bridge) SleepBlocks(call jsre.Call) (goja.Value, error) { blocks = call.Argument(0).ToInteger() } if nArgs >= 2 { - if isNumber(call.Argument(1)) { + if !isNumber(call.Argument(1)) { return nil, errors.New("expected number as second argument") } sleep = call.Argument(1).ToInteger()