Skip to content

[BUG] postMessageToWebview unhandled rejection; dispose() not idempotent #11311

@0xMink

Description

@0xMink

Problem (one or two sentences)

Two reliability issues in src/core/webview/ClineProvider.ts:

  1. postMessageToWebview() does not catch rejections from this.view?.webview.postMessage(...). If the webview is disposed before delivery, this can surface as an unhandled promise rejection.
  2. dispose() is not idempotent. If called multiple times (for example during rapid deactivation/reload), it repeats cleanup work that should run once.

Context (who is affected and when)

Occurs during extension deactivation, reload, or when the panel is closed while messages are in flight. Can produce noisy errors in the Developer Tools console and/or output channel.

Reproduction steps

  1. Environment: Any OS, Roo Code v3.47.3.
  2. Start a task, then immediately close the Roo Code panel or reload the VS Code window.
  3. Open Developer Tools console (Help → Toggle Developer Tools → Console) and observe errors.
  4. For dispose: trigger extension deactivation twice in quick succession (e.g., rapid reload).

Expected result

postMessageToWebview() drops messages safely if the webview is disposed. dispose() is idempotent; subsequent calls are no-ops.

Actual result

postMessageToWebview() can produce unhandled promise rejections after disposal. dispose() re-executes cleanup on repeated calls.

Variations tried (optional)

N/A

App Version

v3.47.3

API Provider (optional)

None

Model Used (optional)

N/A

Roo Code Task Links (optional)

No response

Relevant logs or errors (optional)

Unhandled promise rejection when webview.postMessage() is called after the webview has been disposed (error text varies).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions