-
Notifications
You must be signed in to change notification settings - Fork 110
Description
Hi Team
I am relatively new to NextJS and ArangoDB and have an issue with NextJS 15 SSR and arangojs 10.1.2 and I think the issue is with arangojs.
Issue
In dev mode, everything works perfectly, but once i run pnpm build & pnpm start, the server starts fine, but I get the below on a request:
FetchFailedError: Fetch failed: read ECONNRESET
at Object.fetch (test-build.next\server\chunks\ssr_ae889675..js:1:6980)
at async B.runQueue (test-build.next\server\chunks\ssr_ae889675..js:1:10963)
⨯ Error [FetchFailedError]: Fetch failed: read ECONNRESET
at Object.fetch (test-build.next\server\chunks\ssr_ae889675..js:1:6980)
at async B.runQueue (test-build.next\server\chunks\ssr_ae889675..js:1:10963) {
isSafeToRetry: null,
request: Request {
method: 'POST',
url: 'http://localhost:8529/_db/DB_NAME/_api/cursor',
headers: Headers {
authorization: 'Basic REMOVED',
'x-arango-driver': 'arangojs/10.1.2 (cloud)',
'x-arango-version': '31100',
'content-type': 'application/json'
},
destination: '',
referrer: 'about:client',
referrerPolicy: '',
mode: 'cors',
credentials: 'same-origin',
cache: 'default',
redirect: 'follow',
integrity: '',
keepalive: false,
isReloadNavigation: false,
isHistoryNavigation: false,
signal: [AbortSignal]
},
digest: '1531625992',
[cause]: TypeError: fetch failed
at async Object.fetch (test-build.next\server\chunks\ssr_ae889675._.js:1:6643)
at async B.runQueue (test-build.next\server\chunks\ssr_ae889675..js:1:10963) {
[cause]: [Error: read ECONNRESET] {
errno: -4077,
code: 'ECONNRESET',
syscall: 'read'
}
}
}
I have done some digging (as best as I can) and this only happens if I include next/cookies and have a reference to it:
import {cookies} from "next\headers"
const cookieStore = await cookies();
However, if i remove arangojs and use fetch with an external api, or use postgres it works fine, which makes me think its an issue with arangojs.
How to Reproduce
pnpm create next-app@latest my-app --yes
cd my-app
pnpm i arangojs
open page.tsx, add the "import {cookies} from 'next\headers' , make the Home function async, then at the top of the Home function, add the following:
const cookieStore = await cookies();
const query = aql`
FOR s IN [1..4]
RETURN s
`;
const cursor = await db.query(query);
const result = await cursor.next();
pnpm dev works fine, pnpm build works fine, pnpm start works, but any request fails. comment out the "const cookiestore" line and it all works
Thanks in advance