Closed bilalanees98 closed 6 months ago
Oh, I see. This might be a cacheing issue or similar. Ideally, we could pass a flag to bust-cache -- would that work? Will check with devops
That might be helpful, would need to test it out though.
@janniks any update on this?
There might be an escape hatch to easily do this on the current setup.
Could you test if the following makes a difference for your case? We'll use a global fetch-options object to configure the network call that's being made by the storage methods.
import { getFetchOptions } from '@stacks/network';
const fetchOpts = getFetchOptions();
fetchOpts.headers['Cache-Control'] = 'no-cache';
Run this somewhere before your storage call and it should make the request not-cache the result. Should work with any of the cache-control headers https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
lmk if this works 🙏 if not please re-open
I tried updating fetch-options using the following code:
import { getFetchOptions } from '@stacks/network';
const fetchOpts = getFetchOptions();
fetchOpts.headers['Cache-Control'] = 'no-cache';
const file = await storage.getFile("test-file.json");
On running this code, I got the following error:
Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'Cache-Control')
I also tried updating fetch-options using setFetchOptions functions:
import { setFetchOptions } from '@stacks/network';
setFetchOptions({ headers: {
"Cache-Control": "no-cache",
}});
const file = await storage.getFile("test-file.json");
Running this code results in a CORS error.
Let me know if I'm missing something. Thanks.
@bilal-waheed is working on this from our end. And the above mentioned did not work. Any other possible options in mind @janniks? Oh and apparently I can't re-open an issue.
What version of Stacks.js are you using?
Describe the bug
Unable to read a file stored on Gaia from after it has been put there successfully.
how to reproduce
Use the following piece of code:
However by simply omitting the first getFile call this gets resolved:
Expected behavior
Both pieces of code should return the file after it has been written successfully.
Additional context
This is just an example to illustrate a piece of code in an application that checks whether a file exists (and returns its contents) on GAIA before creating it.