Skip to content

Commit 0706f09

Browse files
committed
Use octokit request to test connectivity
1 parent 0a316bb commit 0706f09

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/git/repository.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as vscode from "vscode";
2-
import * as dns from "dns";
32
import {Octokit} from "@octokit/rest";
43

54
import {handleSamlError} from "../api/handleSamlError";
@@ -144,8 +143,15 @@ export async function getGitHubContext(): Promise<GitHubContext | undefined> {
144143
}
145144

146145
// Check internet connectivity
147-
const isConnected = !!(await dns.promises.resolve("google.com").catch(() => undefined));
148-
if (!isConnected) {
146+
try {
147+
const octokit = new Octokit()
148+
await octokit.request('GET /', {
149+
headers: {
150+
'X-GitHub-Api-Version': '2022-11-28'
151+
}
152+
})
153+
}
154+
catch {
149155
logError(new Error("Cannot fetch github context, unable to connect to the internet"));
150156
return undefined;
151157
}

0 commit comments

Comments
 (0)