I am checking the logs of the SvelteKit SSR server using adapter-node.
I have customised the server.js
to use Express instead of Polka, though not sure if this matters.
There are apparent errors which I believe is when fetch()
tries to read data from backend API and fails for some reason.
This is the console output from I get using docker
:
frontend | TypeError: fetch failed
frontend | at fetch (file:///app/build/handler.js:17895:14)
frontend | at async Object.fetch (file:///app/build/server/index.js:2273:12)
frontend | at async fetch (file:///app/build/server/index.js:991:24)
frontend | at async Promise.all (index 0)
frontend | at async load (file:///app/build/server/chunks/6-0becfa88.js:8:56)
frontend | at async load_data (file:///app/build/server/index.js:1088:16)
frontend | at async file:///app/build/server/index.js:1887:18
This stack trace is unusable, because it lacks the information of what was the function / source code that called fetch()
. Not sure if this is because of how Node.js / Express works, or because lack of TypeScript source map support in some part of the stack or something else. A SvelteKit project has dozens of functions called load()
because that is what every router endpoint has.
What would be a way to make these errors, and SvelteKit error handling in general, more descriptive - e.g. to show the proper caller mapped to its TypeScript source file, the failed page name, failed URL in fetch()
and so on? This would then help to diagnose the underlying problem of what could be wrong with the API calls that fail.