-
-
Notifications
You must be signed in to change notification settings - Fork 935
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
Do not use invalid cache #963
Comments
What's the link? If it's a custom server, please attach some code. What's the cache options? |
Can we exchange by email for links? It's a private project? |
That won't be neccessary I think. If you open the link in your browser, what's the first character of the body?
Also if you provided the full stack trace, that'd be awesome. |
The first character is the Here's the cache: const cache = new KeyvFile({
filename: join(appDataPath, "cache.json"), // the file path to store the data
expiredCheckDelay: 10 * 24 * 3600 * 1000, // ms, check and remove expired data in each ms
writeDelay: 120, // ms, batch write to disk in a specific duration, enhance write performance.
encode: JSON.stringify, // serialize function
decode: JSON.parse // deserialize function
}); And I will try to provide you a bigger stacktrace, thanks |
Thanks, I'll now investigate. |
This is actually weird as Got never does |
If you can provide HTTP headers, that'd awesome as well (you may leave out some of them if they are sensitive). |
Response headers? Because I don't pass any for the request |
yup |
{
'content-type': 'application/json',
'last-modified': 'Wed, 27 Nov 2019 01:56:55 GMT',
'content-encoding': 'gzip',
vary: 'Accept-Encoding',
age: '44979'
} |
@szmarczak I've done more tests. If I simply remove the cache, all is working perfectly. AND I've tried to do a setInterval to request once a second the .json (with the cache) and 1/2 times the data is completely invalid (weird ascii characters), and give the JSON.parse error. |
Could you provide the full error stacktrace? |
How can I get more? Isn't good for you? And I checked: 1/2 times the key is removed in the cache file, so the next time he made the request, it's working, then error, and he removes, etc.. |
Unfortunately I cannot reproduce this one. If you want to you can email me here: I'll be more than happy to help. |
It seems that it's a zero-width space character: |
Just sent to you an email, thanks |
Replied back |
Culprit: kornelski/http-cache-semantics#26 |
Instead, it should make a new request or return the new response without merging anything. I'll move this into #875 |
Describe the bug
Actual behavior
I get
GotError: Unexpected token in JSON at position 0 in ...
when I addresponseType: "json"
.But this happens 2 times out of 5 .. and If I remove the responseType and log the body, all is good..
PS: right before this error there is this warning every time:
(node:34140) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Expected behavior
Should be able to parse JSON, I think got tries to parse before getting full response or something like that
Code to reproduce
or
Checklist
The text was updated successfully, but these errors were encountered: