Skip to content

Drop stale suspend/runtime-error events when debugger is no longer paused#356

Merged
TwitchBronBron merged 3 commits into
masterfrom
fix/dap-stale-suspend-getthreads-crash
May 27, 2026
Merged

Drop stale suspend/runtime-error events when debugger is no longer paused#356
TwitchBronBron merged 3 commits into
masterfrom
fix/dap-stale-suspend-getthreads-crash

Conversation

@chrisdp
Copy link
Copy Markdown
Collaborator

@chrisdp chrisdp commented May 27, 2026

DebugProtocolAdapter.emit defers every event with setTimeout(0). When 'suspend' is queued while paused, isStopped can flip back to false before the timer fires (auto-continue on entry breakpoint, rapid step, etc.). The deferred suspend listener in BrightScriptDebugSession then calls setupSuspendedState → getThreads, which throws Cannot get threads: debugger is not paused as an unhandled rejection.

Re-check isAtDebuggerPrompt inside the deferred dispatch and drop the event if the debugger has already resumed. Same guard applies to 'runtime-error', which routes through the same handler path.

Fixes rokucommunity/vscode-brightscript-language#798

…used

DebugProtocolAdapter.emit defers dispatch via setTimeout(0). If isStopped
flips back to false between queue and fire (e.g. auto-continue on entry
breakpoint, rapid step), the suspend listener in BrightScriptDebugSession
called setupSuspendedState -> getThreads, which threw
"Cannot get threads: debugger is not paused" as an unhandled rejection.

Re-check isAtDebuggerPrompt inside the deferred dispatch and drop the
event if the debugger has already resumed.

Fixes rokucommunity/vscode-brightscript-language#798
@TwitchBronBron TwitchBronBron merged commit 76dab6a into master May 27, 2026
10 checks passed
@TwitchBronBron TwitchBronBron deleted the fix/dap-stale-suspend-getthreads-crash branch May 27, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DAP crash: unhandledRejection - Cannot get threads: debugger is not paused

2 participants