Skip to content

Commit d7ddd6b

Browse files
committed
Fixes #3592 can't connect to remote integration
- Avoids affecting consumers by cloning the response
1 parent 3673cf8 commit d7ddd6b

File tree

2 files changed

+51
-44
lines changed

2 files changed

+51
-44
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
88

99
### Fixed
1010

11+
- Fixes [#3592](https://github.com/gitkraken/vscode-gitlens/issues/3592) - Connecting to an integration via Remotes view (but likely others) doesn't work
12+
13+
## [15.5.1] - 2024-09-16
14+
15+
### Fixed
16+
1117
- Fixes [#3582](https://github.com/gitkraken/vscode-gitlens/issues/3582) - "Delete Branch" option is sometimes unexpectedly missing
1218

1319
## [15.5.0] - 2024-09-12
@@ -5614,7 +5620,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
56145620

56155621
- Initial release but still heavily a work in progress.
56165622

5617-
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/v15.5.0...HEAD
5623+
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/v15.5.1...HEAD
5624+
[15.5.1]: https://github.com/gitkraken/vscode-gitlens/compare/v15.5.0...gitkraken:v15.5.1
56185625
[15.5.0]: https://github.com/gitkraken/vscode-gitlens/compare/v15.4.0...gitkraken:v15.5.0
56195626
[15.4.0]: https://github.com/gitkraken/vscode-gitlens/compare/v15.3.1...gitkraken:v15.4.0
56205627
[15.3.1]: https://github.com/gitkraken/vscode-gitlens/compare/v15.3.0...gitkraken:v15.3.1

src/plus/gk/serverConnection.ts

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -226,57 +226,57 @@ export class ServerConnection implements Disposable {
226226
}
227227

228228
private async handleGkUnsuccessfulResponse(rsp: Response, scope: LogScope | undefined): Promise<void> {
229-
// Too Many Requests
230-
if (rsp.status == 429) {
231-
this.trackRequestException();
232-
return;
233-
}
234-
235-
// Forbidden
236-
if (rsp.status == 403) {
237-
if (rsp.statusText.includes('rate limit')) {
229+
let content;
230+
switch (rsp.status) {
231+
// Forbidden
232+
case 403:
233+
if (rsp.statusText.includes('rate limit')) {
234+
this.trackRequestException();
235+
}
236+
return;
237+
// Too Many Requests
238+
case 429:
238239
this.trackRequestException();
239-
}
240-
return;
241-
}
242-
243-
// Internal Server Error
244-
if (rsp.status == 500) {
245-
this.trackRequestException();
246-
void showGkRequestFailed500WarningMessage(
247-
'GitKraken failed to respond and might be experiencing issues. Please visit the [GitKraken status page](https://cloud.gitkrakenstatus.com) for more information.',
248-
);
249-
return;
250-
}
240+
return;
241+
// Internal Server Error
242+
case 500:
243+
this.trackRequestException();
244+
void showGkRequestFailed500WarningMessage(
245+
'GitKraken failed to respond and might be experiencing issues. Please visit the [GitKraken status page](https://cloud.gitkrakenstatus.com) for more information.',
246+
);
247+
return;
248+
// Bad Gateway
249+
case 502: {
250+
// Be sure to clone the response so we don't impact any upstream consumers
251+
content = await rsp.clone().text();
251252

252-
const content = await rsp.text();
253+
Logger.error(undefined, scope, `GitKraken request failed: ${content} (${rsp.statusText})`);
254+
if (content.includes('timeout')) {
255+
this.trackRequestException();
256+
void showGkRequestTimedOutWarningMessage();
257+
}
258+
return;
259+
}
260+
// Service Unavailable
261+
case 503: {
262+
// Be sure to clone the response so we don't impact any upstream consumers
263+
content = await rsp.clone().text();
253264

254-
// Bad Gateway
255-
if (rsp.status == 502) {
256-
Logger.error(`GitKraken request failed: ${content} (${rsp.statusText})`, scope);
257-
if (content.includes('timeout')) {
265+
Logger.error(undefined, scope, `GitKraken request failed: ${content} (${rsp.statusText})`);
258266
this.trackRequestException();
259-
void showGkRequestTimedOutWarningMessage();
267+
void showGkRequestFailed500WarningMessage(
268+
'GitKraken failed to respond and might be experiencing issues. Please visit the [GitKraken status page](https://cloud.gitkrakenstatus.com) for more information.',
269+
);
270+
return;
260271
}
261-
return;
262272
}
263273

264-
// Service Unavailable
265-
if (rsp.status == 503) {
266-
Logger.error(`GitKraken request failed: ${content} (${rsp.statusText})`, scope);
267-
this.trackRequestException();
268-
void showGkRequestFailed500WarningMessage(
269-
'GitKraken failed to respond and might be experiencing issues. Please visit the [GitKraken status page](https://cloud.gitkrakenstatus.com) for more information.',
270-
);
271-
return;
272-
}
273-
274-
if (rsp.status >= 400 && rsp.status < 500) {
275-
return;
276-
}
274+
if (rsp.status >= 400 && rsp.status < 500) return;
277275

278276
if (Logger.isDebugging) {
279-
void window.showErrorMessage(`GitKraken request failed: ${content} (${rsp.statusText})`);
277+
// Be sure to clone the response so we don't impact any upstream consumers
278+
content ??= await rsp.clone().text();
279+
void window.showErrorMessage(`DEBUGGING: GitKraken request failed: ${content} (${rsp.statusText})`);
280280
}
281281
}
282282

@@ -336,7 +336,7 @@ export class ServerConnection implements Disposable {
336336

337337
if (Logger.isDebugging) {
338338
void window.showErrorMessage(
339-
`GitKraken request failed: ${(ex.response as any)?.errors?.[0]?.message ?? ex.message}`,
339+
`DEBUGGING: GitKraken request failed: ${(ex.response as any)?.errors?.[0]?.message ?? ex.message}`,
340340
);
341341
}
342342
}

0 commit comments

Comments
 (0)