kit icon indicating copy to clipboard operation
kit copied to clipboard

Errors wrapped in a Proxy make working in debug mode difficult

Open kwangure opened this issue 2 years ago • 1 comments

Describe the bug

SvelteKit now wraps errors in a Proxy making it unbearable work with errors and stack traces in VS Code. I upgraded my project to a recent version of SvelteKit and I'm unable to see stack traces in debug mode.

In the terminal, the value is coerced into a string so it works fine, but I spend 95% of my time in debug mode in VS Code's debug console. VS Code's Debug Console doesn't coerce values but maintains a reference to them so that you can do stuff like fold and unfold arrays or objects. It maintains a reference to the proxy, so you don't see the printed error.

image

Reproduction

https://github.com/kwangure/kit-errors-vscode-debug. Go to your VS Code Run and Debug panel and select Launch Dev. Hit play to see the swallowed proxy error.

Logs

No response

System Info

System:
    OS: Linux 5.10 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz
    Memory: 2.83 GB / 5.70 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 19.9.0 - ~/.local/share/pnpm/node
    npm: 9.6.3 - ~/.local/share/pnpm/npm
  npmPackages:
    @sveltejs/adapter-auto: ^2.0.0 => 2.1.0 
    @sveltejs/kit: ^1.5.0 => 1.18.0 
    svelte: ^3.54.0 => 3.59.1 
    vite: ^4.3.0 => 4.3.8

Severity

blocking an upgrade

Additional Information

No response

kwangure avatar May 21 '23 17:05 kwangure

https://github.com/sveltejs/kit/blob/1c1ddd5e34fce28e6f89299d6c59162bed087589/packages/kit/src/runtime/server/utils.js#LL103C1-L111C7

Hmm, not sure what the solution here is -- we're doing this so that we can make sure the stacktrace points to the right place.