-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1396b16
fix(vite): apply `ssrFixStacktrace` to server error
hi-ogawa 5988807
Merge branch 'dev' into vite-ssrFixStacktrace
hi-ogawa 25e865c
test: add test
hi-ogawa 9b7b08f
chore: changeset
hi-ogawa 4eb7194
Merge branch 'dev' into vite-ssrFixStacktrace
hi-ogawa 22eae1a
Merge branch 'dev' into vite-ssrFixStacktrace
hi-ogawa cc9d5f9
refactor: add DevServerHooks.fixStackTrace
hi-ogawa 6708f3e
chore: rename
hi-ogawa 16022e4
Merge branch 'dev' into vite-ssrFixStacktrace
markdalgleish 7b0dd6a
update changeset
markdalgleish 6ded334
rename hook to processRequestError
markdalgleish 09dcf0a
tweak test name
markdalgleish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,10 +95,10 @@ export const createRequestHandler: CreateRequestHandlerFunction = ( | |
|
||
let matches = matchServerRoutes(routes, url.pathname); | ||
let handleError = (error: unknown) => { | ||
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 commentThe 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. |
||
getDevServerHooks()?.processRequestError?.(error); | ||
} | ||
|
||
errorHandler(error, { | ||
context: loadContext, | ||
params: matches && matches.length > 0 ? matches[0].params : {}, | ||
|
@@ -142,7 +142,7 @@ export const createRequestHandler: CreateRequestHandlerFunction = ( | |
} else { | ||
let criticalCss = | ||
mode === ServerMode.Development | ||
? await getDevServerHooks()?.getCriticalCss(_build, url.pathname) | ||
? await getDevServerHooks()?.getCriticalCss?.(_build, url.pathname) | ||
: undefined; | ||
|
||
response = await handleDocumentRequestRR( | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
toprocessRequestError
. 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.
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:
and I am wondering if related to these changes.