-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(remix-dev/vite, server-runtime): pass Vite server errors to vite.ssrFixStacktrace
#8066
Conversation
🦋 Changeset detectedLatest commit: 09dcf0a The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
ssrFixStacktrace
to server errorssrFixStacktrace
to server error
fixStacktrace: vite.ssrFixStacktrace, | ||
// If an error is caught within the request handler, let Vite fix the | ||
// stack trace so it maps back to the actual source code | ||
processRequestError: (error) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heads up that I've renamed this hook from fixStacktrace
to processRequestError
. We want to make sure that all dev server hooks are named in a Vite-agnostic way. As part of this decoupling from Vite, I've also made all of the hooks optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't usually have a strong opinion (and good sense) on naming things, so please feel free and don't hesitate to tweak anything I named.
decoupling from Vite
That sounds like a huge plan!
I'll keep in mind that when doing things in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't see any need for these specific hooks to be used outside of Vite. For now it's mainly just to avoid the weirdness of having references to Vite in @remix-run/server-runtime
😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am getting errors such as:
Error: `line` must be greater than 0 (lines start at line 1)
and I am wondering if related to these changes.
let devServerHooks = getDevServerHooks(); | ||
if (devServerHooks && error instanceof Error) { | ||
devServerHooks.fixStacktrace(error); | ||
if (mode === ServerMode.Development) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this check because we want to make sure these hooks are never called outside of dev, especially since the hooks are coming from a global that can be modified by anyone.
"Error: crash-server-render" | ||
); | ||
await expect(page.locator("main")).toContainText( | ||
"error-stacktrace.tsx:16:11" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really nice 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one! Thanks for the PR 👍
ssrFixStacktrace
to server errorvite.ssrFixStacktrace
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
Closes: #8065
I added
DevServerHooks.fixStacktrace
to passViteDevServer.ssrFixStacktrace
to server runtime, then server runtime uses it to extend default behavior ofhandleError
duringvite dev
.Testing Strategy
I verified the local build on the reproduction repo hi-ogawa/remix-vite-stacktrace-repro#1
I also added playwright test to check error stacktrace line/column in dev error boundary.