Skip to content

fix: return graceful quit-early result when diff worker returns null (fixes #317338)#317341

Open
vs-code-engineering[bot] wants to merge 1 commit into
mainfrom
fix/diff-no-result-error-317338-382ee929f9dab41a
Open

fix: return graceful quit-early result when diff worker returns null (fixes #317338)#317341
vs-code-engineering[bot] wants to merge 1 commit into
mainfrom
fix/diff-no-result-error-317338-382ee929f9dab41a

Conversation

@vs-code-engineering
Copy link
Copy Markdown
Contributor

🔧 Error Fix

Summary

The error no diff result available is thrown in diffProviderFactoryService.ts:151 when editorWorkerService.computeDiff() returns null. This happens when the web worker cannot compute the diff (worker crash, resource unavailability, or model disposal on the worker side). The error propagates as an unhandled rejection through the diff editor view model, reaching error telemetry.

This is a stable-release anomaly affecting 4,679 users with 10,672 hits on version 1.120.0 across all platforms.

Fixes #317338
Recommended reviewer: @hediet

Culprit Commit

Commit range narrowing was inconclusive per the regression scan comment. The error existed in the earliest 1.120.0-insider build under a different bucket ID (8ddfa303) with low volume. The spike on stable suggests increased diff editor usage rather than a specific code change amplifying the failure path. The throw statement has existed since the original implementation.

Code Flow

sequenceDiagram
    participant VM as DiffEditorViewModel
    participant DP as WorkerBasedDocumentDiffProvider
    participant WS as EditorWorkerService
    participant W as Worker

    VM->>DP: computeDiff(original, modified, options, token)
    DP->>WS: computeDiff(uri, uri, options, algorithm)
    WS->>W: $computeDiff(...)
    W-->>WS: null (worker failed)
    WS-->>DP: null
    Note over DP: cancellationToken NOT cancelled
    DP->>DP: throw Error("no diff result available")
    DP-->>VM: rejected promise
    VM->>VM: .catch(rejectIfNotCanceled) re-throws
    Note over VM: Unhandled rejection reaches telemetry
Loading

Affected Files

File Role
src/vs/editor/browser/widget/diffEditor/diffProviderFactoryService.ts Error construction site — throws when worker returns null
src/vs/editor/browser/widget/diffEditor/diffEditorViewModel.ts Caller that catches and re-throws via rejectIfNotCanceled
src/vs/editor/browser/services/editorWorkerService.ts Worker service — legitimately returns null when worker can't compute

Repro Steps

  1. Open a diff editor in VS Code
  2. Trigger a condition where the editor worker cannot compute the diff (e.g., worker process crashes, very large files exhausting worker resources)
  3. The diff computation returns null from the worker
  4. Error "no diff result available" is thrown and reaches telemetry

How the Fix Works

Chosen approach (diffProviderFactoryService.ts:150-157): Instead of throwing an error when result is null, return a graceful quitEarly diff result with empty changes — the same structure already used for the cancellation case at lines 140-148. This fixes the error at the data producer (where the error is constructed) rather than at downstream consumers. The quitEarly: true flag signals to the diff editor UI that the computation did not complete normally, which is the correct semantic for "worker couldn't compute the diff."

Alternatives considered: Adding a try/catch in diffEditorViewModel.ts around the .computeDiff() call was rejected because it would silence the error at a consumer site rather than fixing the producer, violating the data-producer principle.

Recommended Owner

@hediet — owner annotation in the telemetry declaration at line 127 of diffProviderFactoryService.ts, and author of the diff editor infrastructure.

Generated by errors-fix · ● 24.6M ·

…ixes #317338)

When the editor worker service cannot compute a diff (worker crash, resource
unavailability), it returns null. Previously this null was converted into a
thrown error 'no diff result available' that reached error telemetry as an
unhandled rejection (4,679 users affected on 1.120.0 stable).

Instead of throwing, return a quitEarly diff result matching the existing
cancellation handling pattern. The diff editor will show the 'quit early'
state rather than propagating an unhandled error.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 19, 2026 16:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@vs-code-engineering vs-code-engineering Bot requested review from Copilot and hediet May 19, 2026 16:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@vs-code-engineering vs-code-engineering Bot marked this pull request as ready for review May 19, 2026 16:43
@vs-code-engineering vs-code-engineering Bot enabled auto-merge (squash) May 19, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Error] unhandlederror-no diff result available

2 participants