Skip to content

debug: Log errors when loading stored breakpoints/watch expressions (#319805)#319806

Merged
connor4312 merged 1 commit into
microsoft:mainfrom
ishaq2321:fix/debug-storage-silent-data-loss
Jun 3, 2026
Merged

debug: Log errors when loading stored breakpoints/watch expressions (#319805)#319806
connor4312 merged 1 commit into
microsoft:mainfrom
ishaq2321:fix/debug-storage-silent-data-loss

Conversation

@ishaq2321

Copy link
Copy Markdown
Contributor

Summary

Five methods in DebugStorage silently swallowed JSON parse and object construction errors with empty catch blocks. If stored debug data gets corrupted, users lose all their breakpoints, function breakpoints, exception breakpoints, data breakpoints, and watch expressions — with zero indication of failure.

Problem

In src/vs/workbench/contrib/debug/common/debugStorage.ts, these five methods had empty catch (e) { } blocks:

Method Affected Data
loadBreakpoints() All user breakpoints
loadFunctionBreakpoints() All function breakpoints
loadExceptionBreakpoints() All exception breakpoints
loadDataBreakpoints() All data breakpoints
loadWatchExpressions() All watch expressions

Corruption scenario: If IndexedDB/localStorage data becomes corrupted due to sync conflicts, disk errors, crash mid-write, or a serialization bug, JSON.parse() throws — the empty catch drops the exception, the method returns [], and the user is left wondering why all their carefully-set breakpoints just disappeared.

Fix

Replace each empty catch (e) { } with this.logService.error('message', e). The class already has ILogService injected in its constructor but was not using it in these catch blocks.

- } catch (e) { }
+ } catch (e) {
+     this.logService.error('Failed to load breakpoints from storage', e);
+ }

Why this is the right fix

  1. Surfaces corruption — Errors are logged to the developer console and log service, enabling diagnosis
  2. No behavior change — Still returns empty arrays on parse failure (graceful degradation)
  3. Minimal and low-risklogService is already injected via DI, no new dependencies
  4. Follows existing patterns — The loadBreakpoints method already passes this.logService to new Breakpoint(), so the infrastructure is already wired

Testing

  • Existing behavior preserved — errors still caught, empty arrays returned
  • Log output appears in developer console when data is corrupted
  • No functional change to debug workflows

Closes #319805

Co-authored-by: Muhammad Ishaq Khan muhammadishaqkhan.2321@gmail.com

…icrosoft#319805)

Five methods in DebugStorage silently swallowed errors during
JSON.parse() and object construction — if stored debug data gets
corrupted (sync conflicts, disk errors, crash mid-write), all user
breakpoints, function breakpoints, exception breakpoints, data
breakpoints, and watch expressions are silently dropped with zero
indication.

Replace empty catch blocks with logService.error() to surface
corruption events while maintaining the existing fallback behavior
(returning empty arrays).

Closes microsoft#319805

Co-authored-by: Muhammad Ishaq Khan <muhammadishaqkhan.2321@gmail.com>
Copilot AI review requested due to automatic review settings June 3, 2026 20:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR improves diagnosability of debug-state restoration by logging errors when persisted debug data (breakpoints/watch expressions) fails to parse from workspace storage.

Changes:

  • Added logService.error(...) logging when JSON parsing of stored debug artifacts fails.
  • Applied the same logging pattern across multiple stored debug data types (breakpoints, function/exception/data breakpoints, watch expressions).

Comment thread src/vs/workbench/contrib/debug/common/debugStorage.ts
Comment thread src/vs/workbench/contrib/debug/common/debugStorage.ts
@connor4312 connor4312 enabled auto-merge (squash) June 3, 2026 20:38
@connor4312 connor4312 merged commit 82b6922 into microsoft:main Jun 3, 2026
25 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.124.0 milestone Jun 3, 2026
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.

Debug: Silent data loss when stored breakpoints/watch expressions are corrupted

4 participants