Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add ipv4->6 fallback #1475

Merged
merged 1 commit into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he
- fix: custom object `toString()` previews being too short ([vscode#155142](https://github.com/microsoft/vscode/issues/155142))
- fix: show warning if console output length is hit ([vscode#154479](https://github.com/microsoft/vscode/issues/154479))
- fix: improve variable and repl performance in large projects ([#1433](https://github.com/microsoft/vscode-js-debug/issues/1433))
- fix: add ipv4->6 fallback ([vscode#167353](https://github.com/microsoft/vscode/issues/167353))

## v1.74 (November 2022)

Expand Down
17 changes: 13 additions & 4 deletions src/adapter/resourceProvider/basicResourceProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*--------------------------------------------------------*/

import dataUriToBuffer from 'data-uri-to-buffer';
import { LookupAddress, promises as dns } from 'dns';
import got, { Headers, OptionsOfTextResponseBody, RequestError } from 'got';
import { inject, injectable, optional } from 'inversify';
import { CancellationToken } from 'vscode';
Expand Down Expand Up @@ -91,10 +92,18 @@ export class BasicResourceProvider implements IResourceProvider {

const response = await this.requestHttp(url, options, cancellationToken);

// Try 127.0.0.1 if localhost fails, see https://github.com/microsoft/vscode/issues/140536#issuecomment-1011281962
// The statusCode will be 503 on ECONNREFUSED
if (response.statusCode === 503 && parsed.hostname === 'localhost') {
parsed.hostname = '127.0.0.1';
// Try the other net family if localhost fails,
// see https://github.com/microsoft/vscode/issues/140536#issuecomment-1011281962
// and later https://github.com/microsoft/vscode/issues/167353
if (response.statusCode === 503 && parsed.hostname === 'localost') {
let resolved: LookupAddress;
try {
resolved = await dns.lookup(parsed.hostname);
} catch {
return response;
}

parsed.hostname = resolved.family === 6 ? '127.0.0.1' : '::1';
return this.requestHttp(parsed.toString(), options, cancellationToken);
}

Expand Down