-
So I'm tring to figure out why I'm getting this error only on the first call after an idle time. I'm 99% sure it's something related to directus configuration more than a nuxt/nuxt-directus related issue, but I wanted to ask here first. The only logical conclusion is that directus or nuxt have a max response time threashold, so if directus gets a call after N minutes of no requests received it could take it, lets say, 200ms to give the response back, but nuxt wait only 150ms, so it gives me the FetchError. On the other end if I make the request right after the first one (the FetchError one or any other request for the next 5-10minutes) I get a successfull response every time with an average of 70ms. How can I troubleshoot this? example of a const { getItems } = useDirectusItems();
const { getThumbnail: img } = useDirectusFiles();
const { data: wallpaper } = await useAsyncData('wallpaper', () => getItems({
collection: "website",
params: {
fields: [
"gallery_background.id",
"gallery_background.filename_download",
],
}
})); |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 13 replies
-
An additional note could be that is mainly related to images (all optimized via directus in avif/webp, max 600KB and usually 1-4 per page). |
Beta Was this translation helpful? Give feedback.
-
The error I get from the browser is something along the lines of: |
Beta Was this translation helpful? Give feedback.
-
@rijkvanzanten Do you have an idea? I'm not sure if this is a nuxt directus related issue. |
Beta Was this translation helpful? Give feedback.
-
So, I've only now noticed that I didn't point out that the images I'm requesting are all transformations of the originals that are on directus local storage (I'm mainly transforming them to webp from jpeg). And yes, this happens on first request, if I refresh the page right after I do get the images. If I let sit nuxt/directus idle for 15minutes (the only timeframe I'm sure of) I do get this problem, but only on first load. Again, If I refresh the page or continue browsing the website everything works fine. I did catch this event under the network tab and it never exceeded 150ms (the slowest one I've seen was 149ms), so I'm starting to think it's not something related to rate or threshold configuration. Looking at the generated html I can see the correct url with both id and transformation parameters, so the issue is not the rest api but more like the actual file retrieval. Lastly, my config is based on this docker-compose and deployed on a VPS confort on OVH. |
Beta Was this translation helpful? Give feedback.
-
I'm typing this mainly as a backlog, but I did have some time today and yes: nuxt (nor nuxt-directus) doesn't have anything to do with this problem. The first request of an image (without any conversion) via rest api gives Currently the directus files aren't publicly available, they are served via an access token from a read-only user (and the token is appended in the rest url) |
Beta Was this translation helpful? Give feedback.
-
So, @rijkvanzanten I'm sorry to disturb you, but I really need you on this: So my actual question: The token currently is a static token from a ReadOnly_API user (no email) with a read only role and the token is inside nuxt-directus options in nuxt.confg.ts. |
Beta Was this translation helpful? Give feedback.
-
Since I'm now 100% sure that my problem is related with directus itself, and nuxt-directus doesn't have anything to do with it, I'm moving this discussion to directus/directus. |
Beta Was this translation helpful? Give feedback.
-
I've described the actual solution here.
|
Beta Was this translation helpful? Give feedback.
I've described the actual solution here.