-
-
Notifications
You must be signed in to change notification settings - Fork 942
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
got() does not return when a response is in cache, but has been revalidated #2170
Comments
After some investigation I have found that the problem occurs when cache revalidation with turned on compression results in a 304 status code. (I have added a test for the case in this pr) It seems like the problem stems from a questionable workaround in I think that the aforementioned hack combined with the partial implementation of the Removing that workaround fixed the problem for me. However, I'm not sure about the reasoning behind it and if removing it would break something else. However, there's another workaround I've found that works locally for me (alas not so cleanly): backfill the diff --git a/index.js b/index.js
index 6e2d40b..ff2d6a9 100644
--- a/index.js
+++ b/index.js
@@ -28,6 +28,7 @@ export default class Response extends ReadableStream {
read() {
this.push(body);
this.push(null);
+ this.complete = true;
},
});
@@ -35,5 +36,6 @@ export default class Response extends ReadableStream {
this.headers = lowercaseKeys(headers);
this.body = body;
this.url = url;
+ this.complete = false;
}
} I'm mentioning a change to another packages here because it looks like it's maintained by the same group of people. |
|
The underlying cache package isn't maintained anymore. It will be replaced. |
Describe the bug
Actual behavior
I am trying to use Github's API, but enabling Got's cache causes some issues.
Output:
No issue with no cache.
While investigating, I found that Github's responses have the following header:
cache-control: private, max-age=60, s-maxage=60
.If the second request is done within 60s of the first, the result is better (we get a usable response), however some properties of the returned object (eg:
.complete
) are still missing.For example, reducing the delay between the two requests to 1s generates the following output:
Expected behavior
got()
should be able to work with responses retrieved from the cache, whether they have been revalidated or not.Fixing
.complete
when using a cache has already been attempted in the past: 9e15d88.Code to reproduce
See above.
Checklist
The text was updated successfully, but these errors were encountered: