Skip to content

fix: handle dangling promise rejection in external ingest upload (fixes #317056)#317064

Open
vs-code-engineering[bot] wants to merge 1 commit into
mainfrom
fix/external-ingest-unhandled-rejection-317056-03585ff7d4257f07
Open

fix: handle dangling promise rejection in external ingest upload (fixes #317056)#317064
vs-code-engineering[bot] wants to merge 1 commit into
mainfrom
fix/external-ingest-unhandled-rejection-317056-03585ff7d4257f07

Conversation

@vs-code-engineering
Copy link
Copy Markdown
Contributor

🔧 Error Fix

Summary

Error: Ingest not found (404) for document — an unhandled promise rejection from the external ingest upload pool in the Copilot extension's workspace chunk search.

Root Cause: In externalIngestClient.ts, when a document upload returns HTTP 404, the code throws at line 425. The upload promise p is correctly tracked in the uploading set and handled via Promise.all(uploading). However, p.finally(...) (line 432) creates a new promise whose rejection is never caught. When p rejects, the .finally() return promise also rejects — and since no handler is attached to it, Node.js fires an unhandledRejection event that reaches error telemetry.

Fixes #317056
Recommended reviewer: @mjbvz

Culprit Commit

Field Value
Commit 5137aa4525bcdef5f337d85e9f0078a26ae62585
Author @mjbvz
Message Cancel external ingest upload on 404 (num 4211)
Why This commit introduced the throw on 404 at line 425, which rejects promise p. Combined with the pre-existing p.finally(...) pattern that discards its return value, this created a dangling rejected promise.

Code Flow

sequenceDiagram
    participant PI as performIngestion
    participant IIFE as uploadIIFE
    participant FIN as finallyReturn
    participant PA as PromiseAll
    participant TEL as Telemetry

    PI->>IIFE: start upload
    IIFE->>IIFE: makeRequest returns 404
    IIFE->>IIFE: throw ExternalIngestRequestError line 425
    IIFE-->>FIN: finally callback runs rejected promise
    IIFE-->>PA: rejection propagates via uploading set
    FIN-->>TEL: unhandled rejection no catch on finally return
Loading

Affected Files

File Role
extensions/copilot/src/platform/workspaceChunkSearch/node/codeSearch/externalIngestClient.ts Contains the upload promise pool with the dangling .finally()

Repro Steps

  1. Open a workspace with Copilot external ingest enabled
  2. The backend ingest endpoint returns 404 for a document (e.g., expired ingest session)
  3. The 404 triggers the throw at line 425, rejecting promise p
  4. p.finally(...) propagates the rejection to its return promise
  5. Since the .finally() return is never caught, an unhandled rejection fires

How the Fix Works

Chosen approach (externalIngestClient.ts): Added .catch(() => {}) to the end of the p.finally(...) chain. This prevents the dangling promise from firing an unhandled rejection. The actual error is still correctly propagated via Promise.all(uploading) through the original p reference in the uploading set — the fix is at the data producer of the unhandled rejection (the uncaught .finally() return), not at the crash site.

Recommended Owner

@mjbvz — author of the culprit commit and primary maintainer of the external ingest client.

Generated by errors-fix · ● 34.2M ·

#317056)

The p.finally() call creates a new promise whose rejection is never
caught. When a 404 rejects the upload promise p, the .finally() return
also rejects as an unhandled rejection hitting telemetry. The actual
error is properly handled via Promise.all(uploading) — this just
prevents the duplicate unhandled rejection from the .finally() chain.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 18, 2026 16:29
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 mjbvz May 18, 2026 16:32
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 18, 2026 16:32
@vs-code-engineering vs-code-engineering Bot enabled auto-merge (squash) May 18, 2026 16:32
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.

[Regression] [Error] [GitHub.copilot-chat] unhandlederror-Ingest not found (404) for document

2 participants