Debugger's `list` command throws TypeError: Cannot read properties of null (reading 'list')

Version

v17.9.0

Platform

No response

Subsystem

No response

What steps will reproduce the bug?

$ node inspect -e "const a = 1"
debug> c
debug> list()

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior?

Debugger should throw ERR_DEBUGGER_ERROR just like sb() command since the runtime context has been already destroyed.

debug> list()
> 1 const a = 1
debug> c
< Waiting for the debugger to disconnect...
< 
debug> list()
node:internal/debugger/inspect_repl:362
      throw new ERR_DEBUGGER_ERROR('Requires execution to be paused');
      ^
debug> sb(1)
node:internal/debugger/inspect_repl:362
      throw new ERR_DEBUGGER_ERROR('Requires execution to be paused');
      ^

What do you see instead?

debug> list()
> 1 const a = 1
debug> c
< Waiting for the debugger to disconnect...
< 
debug> list()
node:internal/debugger/inspect_repl:638
    return selectedFrame.list(delta).then(null, (error) => {
                         ^

Uncaught TypeError: Cannot read properties of null (reading 'list')
    at list (node:internal/debugger/inspect_repl:638:26)
    at REPL3:1:1
    at Script.runInContext (node:vm:139:12)
    at Object.runInContext (node:vm:289:6)
    at REPLServer.controlEval (node:internal/debugger/inspect_repl:578:25)
    at bound (node:domain:421:15)
    at REPLServer.runBound [as eval] (node:domain:432:12)
    at REPLServer.onLine (node:repl:893:10)
    at REPLServer.emit (node:events:527:28)
    at REPLServer.emit (node:domain:475:12)
debug> sb(1)
node:internal/debugger/inspect_repl:362
      throw new ERR_DEBUGGER_ERROR('Requires execution to be paused');
      ^

Additional information

No response