Chat image download from URL has no timeout and ignores its cancellation token
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- electron, typescript
Research direction
Start in src/vs/platform/webContentExtractor/node/sharedWebContentExtractorService.ts, where readImageWithMetadata calls fetch without a signal or deadline. Read the existing stubs in src/vs/platform/webContentExtractor/test/node/sharedWebContentExtractorService.test.ts, then add a test that checks a signal is passed and that cancelling the token aborts the request. Done when the fetch is bounded by a timeout and tied to the CancellationToken, and the tests pass.
Written by the indexing model from the issue text.
Description
Does this issue occur when all extensions are disabled?: Yes (core code path, no extension involved)
- VS Code Version:
mainat 742a9ae378720f2526ed7128fbc47ec2a285f1b1 (found by reading the source, not reproduced in a build) - OS Version: any
SharedWebContentExtractorService.readImageWithMetadata downloads an image from an arbitrary URL with a plain fetch and no deadline:
The CancellationToken is checked once before the request and is never connected to the fetch, so even a cancelled token cannot abort it. In practice every workbench caller passes CancellationToken.None anyway:
- chat drag and drop:
chatDragAndDrop.ts#L446 - attachments:
chatAttachmentModel.ts#L203 - input part:
chatInputPart.ts#L2900 - copy image:
chatImageActions.ts#L50 - image generation batch:
chatImageGenerationBatchPart.ts#L282 - download:
workbench/browser/download.ts#L36
Steps to Reproduce:
- Serve a URL that accepts the connection and never sends a response (for example
nc -l 8080). - Drag
http://localhost:8080/a.pnginto the Chat input, or paste it as an image attachment. - Nothing aborts the request, so the attachment stays pending until Node's fetch gives up after undici's default headers/body timeouts (300 s each), and there is no way to cancel it from the UI.
Expected: the request is bounded and cancellable. A small fix is to pass a signal that combines a timeout with the token, e.g.
const controller = new AbortController();
const listener = token.onCancellationRequested(() => controller.abort());
try {
const response = await fetch(uri.toString(true), {
headers: { ... },
signal: AbortSignal.any([controller.signal, AbortSignal.timeout(30_000)]),
});
...
} finally {
listener.dispose();
}
The existing tests in src/vs/platform/webContentExtractor/test/node/sharedWebContentExtractorService.test.ts stub fetch, so a case asserting that a signal is passed and that cancelling the token aborts it would fit there. I can send a PR with that if it helps.
- Dominant language
- TypeScript
- Stars
- 196k
- Forks
- 43.9k
- Avg merge
- 12h 49m
- Merged PRs (30d)
- 682
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/vscode
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
testplan-item
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
testplan-item
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
testplan-item
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
All issues in microsoft/vscode
Similar issues
-
bug done
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
neavo/LinguaGacha#1124 ·
Maintainers usually reply within 1 day
-
[fullsend] E2E: backstage-microsoft-auth — catalogQuery missing error handler for network errorsPossibly taken @fullsend-ai-coder claimed this today. Opene2e-failure ready-to-code
Difficulty 2/5 Under an hour Newbie friendliness 78/100
redhat-developer/rhdh-plugin-export-overlays#4821 · 1 comment ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
brylie/mission-island#225 ·
Maintainers usually reply within 1 day
-
status/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
google-gemini/gemini-cli#30412 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
sagemathinc/sagebrush#1683 ·
Maintainers usually reply within 1 day