Skip to content

Commit efeba57

Browse files
authored
ci(core): Request should not throw on 304 status (aws#6400)
## Problem Only 200-299 are treated as "response.ok" responses by fetch. However, 304's (content not modified) are valid response codes as well ## Solution If the status code is 304 then don't throw --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent c767cee commit efeba57

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/core/src/shared/request.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ class FetchRequest {
9999
}
100100

101101
async #throwIfBadResponse(request: RequestParams, response: Response, url: string) {
102-
if (response.ok) {
102+
/**
103+
* response.ok only returns true for 200-299.
104+
* We need to explicitly allow 304 since it means the cached version is still valid
105+
*/
106+
if (response.ok || response.status === 304) {
103107
return
104108
}
105109

0 commit comments

Comments
 (0)