Skip to content

[Feature] Avoid crash when removing excluded or unsupported workspace folder #2794

Description

@EmmaYuan1015

Summary

When a workspace folder is removed, the extension may throw a runtime error if that folder was never added to the project cache.

Actual Behavior

onFolderRemoved assumes a cached project exists and can attempt property access on undefined, causing an exception.

Expected Behavior

If the folder is not cached, removal should be safely skipped without throwing, and other extension workflows should continue normally.

Root Cause

ProjectsStorage.getFolder(...) can return undefined, but onFolderRemoved did not previously guard for that case.

Proposed Fix
Add a null/undefined guard in onFolderRemoved
If cache miss: log debug message and return safely.
If cache hit: call appLauncher.dispose() and then ProjectsStorage.delFolder(...)

Acceptance Criteria
Removing an uncached folder does not throw.
Removing a cached folder still disposes resources and clears cache correctly.
Workspace folder add/remove events remain stable across mixed project types.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions