-
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-react): An error in MetaFunction
or LinkFunction
should render ErrorBoundary
#3674
Conversation
MetaFunction
or LinkFunction
should render ErrorBoundary
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 think I must be missing something here, but I don't see any behavioral changes here. I'm pretty sure the code does exactly the same thing before and after.
1bd7cc0
to
8da006b
Compare
|
@@ -470,6 +477,32 @@ async function handleDocumentRequest({ | |||
} catch (error: any) { | |||
responseStatusCode = 500; | |||
|
|||
// next up, we'll verify that `meta` returned without error | |||
try { | |||
await callRouteMeta({ |
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 wonder if there's any use in distinguishing errors thrown when calling a route meta()
function here from errors thrown when rendering the <meta>
tags. The rendering is far more in our control and we should be able to be pretty confident it won't throw render errors. The exported meta
function contents are out of our control - but we do control the execution of it in our own <Meta>
component.
Spitballing here but what if we did something like this in <Meta>
for (let match of matches) {
let routeId = match.route.id;
try {
let routeMeta = routeModule.meta({ data, parentsData, params, location })
...
} catch (error) {
// Re-throw the error and associate it with the routeId that threw it
throw new MetaError(routeId, error);
}
}
Then we could identify the error in this handleDocumentRequest
catch
block as a meta-specific error (via instanceof MetaError
) and know the routeId
that caused it and look for the nearest ancestor boundary (i.,e., prevent re-calling the problematic meta
on the second pass - but attempt to call the successful ones above it).
This is effectively what we're doing with the mutable boundaryIds (identifying how deep we got) - but we have no choice there since it's React calling them, not us. meta
isn't subject to that same restriction so we could be a bit more direct in the identification of the problematic routeId
.
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.
Actually we'd still need some logic changes in Meta
to do that too I think. It doesn't have the concept of renderableMatches
that we have for getDocumentHeaders
which I think is what it would need to not call child's meta function on the second pass if we had identified parent as the renderable boundary.
f2c785c
to
d59d138
Compare
Signed-off-by: Logan McAnsh <logan@mcan.sh>
Signed-off-by: Logan McAnsh <logan@mcan.sh>
Signed-off-by: Logan McAnsh <logan@mcan.sh>
Signed-off-by: Logan McAnsh <logan@mcan.sh>
Signed-off-by: Logan McAnsh <logan@mcan.sh>
d59d138
to
aae7c22
Compare
Signed-off-by: Logan McAnsh <logan@mcan.sh>
895def7
to
7fc50e0
Compare
Signed-off-by: Logan McAnsh <logan@mcan.sh>
Signed-off-by: Logan McAnsh <logan@mcan.sh>
Signed-off-by: Logan McAnsh <logan@mcan.sh>
Signed-off-by: Logan McAnsh <logan@mcan.sh>
Signed-off-by: Logan McAnsh <logan@mcan.sh>
56fda0d
to
d819080
Compare
Signed-off-by: Logan McAnsh <logan@mcan.sh>
b373654
to
6e57656
Compare
Closing for now, can re-open if/when we come back to this. |
Signed-off-by: Logan McAnsh logan@mcan.sh
Closes #3140
Testing Strategy: