3 months ago
I am getting this error when trying to connect to my convex backend via fetchQuery in Next.JS, looking at the convex logs, I see the statuses show up as 200, but in Next.JS its throwing an internal error.
⨯ TypeError: fetch failed
[cause]: AggregateError:
at async au.queryInner (.next/server/chunks/ssr/0eed8_convex_dist_esm_nextjs_index_714fca5b.js:1:18851)
at ignore-listed frames {
at async au.query (.next/server/chunks/ssr/0eed8_convex_dist_esm_nextjs_index_714fca5b.js:1:18388)
at async aO (.next/server/chunks/ssr/0eed8_convex_dist_esm_nextjs_index_714fca5b.js:2:2138)
at async i (.next/server/chunks/ssr/[root-of-the-server]__d3adff91._.js:1:2445) {
digest: '378646136',
⨯ TypeError: fetch failed
at async au.queryInner (.next/server/chunks/ssr/0eed8_convex_dist_esm_nextjs_index_714fca5b.js:1:18851)
at async au.query (.next/server/chunks/ssr/0eed8_convex_dist_esm_nextjs_index_714fca5b.js:1:18388)
at async aO (.next/server/chunks/ssr/0eed8_convex_dist_esm_nextjs_index_714fca5b.js:2:2138)
at async i (.next/server/chunks/ssr/[root-of-the-server]__d3adff91._.js:1:2445) {
digest: '378646136',
[cause]: AggregateError:
at ignore-listed frames {
code: 'ETIMEDOUT'
}
}
⨯ TypeError: fetch failed
at async au.queryInner (.next/server/chunks/ssr/0eed8_convex_dist_esm_nextjs_index_714fca5b.js:1:18851)
at async au.query (.next/server/chunks/ssr/0eed8_convex_dist_esm_nextjs_index_714fca5b.js:1:18388)
at async aO (.next/server/chunks/ssr/0eed8_convex_dist_esm_nextjs_index_714fca5b.js:2:2138)
at async i (.next/server/chunks/ssr/[root-of-the-server]__d3adff91._.js:1:2445) {
digest: '3018479579',
[cause]: AggregateError:
at ignore-listed frames {
code: 'ETIMEDOUT'
}
}
Pinned Solution
3 months ago
I feel like the solution should be this, https://github.com/vercel/next.js/discussions/70423, I monitored the CURL request and it took 750ms to get back to the railway ssh, and from what I can see the default timeout is 250ms, I'll try setting it to 1 second to see if that fixes it, and additionality, if that does fix it, I'll self host convex my self via railway and use the internal networking.
15 Replies
3 months ago
can you share the url you are using? pay attention that for internal request you should use http not https , I'm able to send request using the internal url + the port, something like:http://XXX-YYY.railway.internal:8080
3 months ago
The error happens because the Next.js app is trying to fetch data from the Convex backend using the wrong URL. For internal requests, you should use the internal URL with http and the correct port, not https. Using https or a public URL can cause timeouts (ETIMEDOUT) even if the backend shows a 200 status. Updating the fetch URL to the internal one usually fixes this error.
3 months ago
const data = await (await fetch${process.env.API_URL}/api/data, { cache: "no-store" })).json();
3 months ago
I am not self hosting convex my self, the convex URL is provided via the convex.dev website, and it works locally, and if I spam refresh I can get it to work sometimes. I asked in the convex discord, they said its an issue with IPV6.
rakesh051204
const data = await (await fetch${process.env.API_URL}/api/data, { cache: "no-store" })).json();
3 months ago
I am not fetching like this, I am using the usePreloadQuery provided by convex.
fra
can you share the url you are using? pay attention that for internal request you should use http not https , I'm able to send request using the internal url + the port, something like:http://XXX-YYY.railway.internal:8080
3 months ago
I am using the convex.cloud URL, not an internal URL, I am not self hosting convex my self.
3 months ago
can you try to connect to your container via ssh and try to ping convex? At least you can understand if it is blocked by railway or not
fra
can you try to connect to your container via ssh and try to ping convex? At least you can understand if it is blocked by railway or not
3 months ago
How do you ping inside of railways docker container? there is no ping, curl or wget nor busybox installed, and installing ping via apt, says I dont have permission to run it, even after setting the chmod
fra
can you try to connect to your container via ssh and try to ping convex? At least you can understand if it is blocked by railway or not
3 months ago
I just installed curl via apt, and ran it on my production url, and it processes the response with success and I can see its the correct response text as well.
3 months ago
I don’t have direct SSH access to the Railway container. However, I tested network connectivity from within the container by installing curl via apt and making a request to the Convex production URL. The request completed successfully, and the response content matches the expected output.
This indicates that outbound connectivity to Convex from Railway is working and does not appear to be blocked.
samhoque
I just installed curl via apt, and ran it on my production url, and it processes the response with success and I can see its the correct response text as well.
3 months ago
ok, now we know that railway doesn't block the request, can you please console.log the url passed when you initialise the client? I wonder if by any reason the env is empty or wrong.
fra
ok, now we know that railway doesn't block the request, can you please console.log the url passed when you initialise the client? I wonder if by any reason the env is empty or wrong.
3 months ago
How could that be when the error is a timeout error if the .env is empty or wrong? and in the convex backend logs, I can see the request passes with success. (if the URL was wrong, then the convex backend wouldn't log which functions were called and showing a success audit log)
fra
ok, now we know that railway doesn't block the request, can you please console.log the url passed when you initialise the client? I wonder if by any reason the env is empty or wrong.
3 months ago
I feel like the solution should be this, https://github.com/vercel/next.js/discussions/70423, I monitored the CURL request and it took 750ms to get back to the railway ssh, and from what I can see the default timeout is 250ms, I'll try setting it to 1 second to see if that fixes it, and additionality, if that does fix it, I'll self host convex my self via railway and use the internal networking.
3 months ago
sorry I misunderstood part of the message, if the request hit convex then the env it's fine. my idea was that maybe the code didn't picked up the convex url and was sending the request to the wrong url....but i you see the request in convex then it means the code is fine, yeah try to increase the timeout on the client
fra
sorry I misunderstood part of the message, if the request hit convex then the env it's fine. my idea was that maybe the code didn't picked up the convex url and was sending the request to the wrong url....but i you see the request in convex then it means the code is fine, yeah try to increase the timeout on the client
3 months ago
Increasing the timeout fixed the issue, but the website is really slow, I am guessing I need to selfhost convex my self.
Status changed to Solved brody • 3 months ago


