Skip to content

Vite dev: error stacktrace is a few lines off in dev server log #8065

@hi-ogawa

Description

@hi-ogawa

Reproduction

I created a reproduction with a potential user-side workaround in https://github.com/hi-ogawa/remix-vite-stacktrace-repro.
(I forked to stackblitz but it seems ssrFixStacktrace is broken on stackblitz runtime currently, so the same thing cannot be reproduced. It's not useful but just for reference https://stackblitz.com/edit/hi-ogawa-remix-vite-stacktrace-repro-yanxgp.)

I don't know about the inner working but I think currently vite ssr requires applying ssrFixStacktrace for server error. As shown in the repro, currently line/column in stacktrace is a little off without this.

I found that the best timing to apply this is already provided by handleError convention, so currently there is a user-side workaround by making use of external plugin to provide ViteDevServer instance in user code (for example, @vavite/expose-vite-dev-server or @hiogawa/vite-import-dev-server).

However, I was wondering if it would make sense to apply ssrFixStacktrace by default in remix plugin in some way.
I haven't think about how such implementation would look like yet, but I thought I would create this issue first in case other people also noticed something odd about error stack when testing remix vite.

System Info

  System:
    OS: Linux 6.6 Arch Linux
    CPU: (12) x64 AMD Ryzen 5 5625U with Radeon Graphics
    Memory: 4.78 GB / 14.98 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 18.16.0 - ~/.volta/tools/image/node/18.16.0/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 9.5.1 - ~/.volta/tools/image/node/18.16.0/bin/npm
    pnpm: 8.10.5 - ~/.asdf/installs/pnpm/8.10.5/bin/pnpm
  Browsers:
    Chromium: 119.0.6045.159
  npmPackages:
    @remix-run/dev: ^2.3.0 => 2.3.0 
    @remix-run/eslint-config: ^2.3.0 => 2.3.0 
    @remix-run/node: ^2.3.0 => 2.3.0 
    @remix-run/react: ^2.3.0 => 2.3.0 
    @remix-run/serve: ^2.3.0 => 2.3.0 
    vite: ^5.0.0 => 5.0.0 

Used Package Manager

pnpm

Expected Behavior

server error stack should be correct

Actual Behavior

server error stack is a few lines off

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions