You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been suffering from incorrect error locations for a long time and was very excited about #10769 and version 1.25.1.
However, it seems to be about server rendering and some IDE, and not related to errors in code executed in hooks.server.js.
Even in a stackblitz environment, the phenomenon is well reproduced. In the project I linked there is only a 2 line difference, but it is not consistent at all. Sometimes it is smaller than it actually is, but most of the time they report a larger number.
I keep the asynchronous infinite loop executed in hooks.server.js residing on the server like a daemon. And the values calculated by the infinite loop are frequently referenced and output by several pages of svelte. I don't think this is an overly unusual structure.
In that infinite loop, errors will occur frequently, and I want to quickly find their location. Currently I am having a very hard time.
Since I'm having a really hard time, I'd like to know at least a temporary solution.
For example, in #10769, I checked the following link: https://github.com/sveltejs/kit/blob/master/packages/kit/src/runtime/server/utils.js#L98
I found this to be of great help in making this temporary fix. I hope there is something similar for my case. I am not skilled enough to find it myself. Please help me.
console.log('run: hooks.server.js (line 1)');
setTimeout(() => {
// Dummy code to place the error location in the middle of the file. (line 4)
console.log('error soon (line 6)');
}, 3000);
setTimeout(() => {
console.log('<--- line number 10', new Error().stack);
throw new Error('<---- line number 11');
}, 4000);
setTimeout(() => {
console.log('dummy'); //(line 15)
console.log('dummy'); //(line 17)
console.log('dummy'); //(line 19)
}, 10000);
package.json:
"@sveltejs/kit": "1.25.1"
Logs
run: hooks.server.js (line 1)
page option: { prerender: false, ssr: false }
error soon (line 6)
<--- line number 10 Error
at Timeout.eval (/home/projects/sveltejs-kit-template-default-wsaice/src/hooks.server.js:12:37)
at listOnTimeout (node:internal/timers:62:4448)
at processTimers (node:internal/timers:62:5285)
at <anonymous> (https://sveltejskittemplatedefaultwsai-dctb.w-credentialless.staticblitz.com/blitz.d6c42aca.js:334:292836)
at <anonymous> (https://sveltejskittemplatedefaultwsai-dctb.w-credentialless.staticblitz.com/blitz.d6c42aca.js:334:293145)
Error: <---- line number 11
at Timeout.eval (/home/projects/sveltejs-kit-template-default-wsaice/src/hooks.server.js:13:8)
at listOnTimeout (node:internal/timers:62:4448)
at processTimers (node:internal/timers:62:5285)
at <anonymous> (https://sveltejskittemplatedefaultwsai-dctb.w-credentialless.staticblitz.com/blitz.d6c42aca.js:334:292836)
at <anonymous> (https://sveltejskittemplatedefaultwsai-dctb.w-credentialless.staticblitz.com/blitz.d6c42aca.js:334:293145)
@lzdetourer Is this specific to using setTimeout? If so there's not much really do for that or any other asynchronous errors since those can't be intercepted by SvelteKit or Vite.
The errors need to be caught by the framework somehow to fix the stack and that can't happen if they're thrown asynchronously without being awaited.
@lzdetourer Is this specific to using setTimeout? If so there's not much really do for that or any other asynchronous errors since those can't be intercepted by SvelteKit or Vite.
The errors need to be caught by the framework somehow to fix the stack and that can't happen if they're thrown asynchronously without being awaited.
It is used in setTimeout and async/await infinite loop.
But since it's so painful to me, I don't mind changing the method as long as I can find the location of the error. For example, it is enough to know the exact location of the Error object generated in the try-catch statement inside async.
eltigerchino
changed the title
The error in hooks.server.js still reports the wrong location.
async errors reports the wrong location during SSR
Oct 9, 2024
eltigerchino
changed the title
async errors reports the wrong location during SSR
async errors report the wrong location during SSR
Oct 9, 2024
Describe the bug
I've been suffering from incorrect error locations for a long time and was very excited about #10769 and version 1.25.1.
However, it seems to be about server rendering and some IDE, and not related to errors in code executed in
hooks.server.js
.Even in a
stackblitz
environment, the phenomenon is well reproduced. In the project I linked there is only a 2 line difference, but it is not consistent at all. Sometimes it is smaller than it actually is, but most of the time they report a larger number.I keep the asynchronous infinite loop executed in
hooks.server.js
residing on the server like a daemon. And the values calculated by the infinite loop are frequently referenced and output by several pages ofsvelte
. I don't think this is an overly unusual structure.In that infinite loop, errors will occur frequently, and I want to quickly find their location. Currently I am having a very hard time.
Since I'm having a really hard time, I'd like to know at least a temporary solution.
For example, in #10769, I checked the following link: https://github.com/sveltejs/kit/blob/master/packages/kit/src/runtime/server/utils.js#L98
I found this to be of great help in making this temporary fix. I hope there is something similar for my case. I am not skilled enough to find it myself. Please help me.
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-wsaice?file=jsconfig.json
hooks.server.js:
package.json:
Logs
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: