Hi - Have a weird one related to the express getLoadContext and useLoaderData.
Now I figure this getLoadContext function should be made quite safe, but I've recently run into a situation where the following appears to happen (intermittently)
- App is running fine
- Some error occurs on the express server, which is likely triggering an error when getLoadContext is run (redis timeout/restart issues)
- getLoadContext throws an error and useLoaderData in the page appears to return the rendered express error page in HTML instead of either the results from its loader (obviously unexpected in that case), or just useLoaderData throwing a JS error itself so nothing else runs.
That behavior is breaking the TypeScript contract of useLoaderData<typeof loader>(), so I'm getting a knock-on error below it.
I'm able to cleanly reproduce this error, so I'll make a reproducible example, but maybe some guidance on how to ensure the getLoadContext is ensured to fail gracefully/cleanly here would be great in case of a problem outside Remix.
As an example, if I threw an error "FOOBAR" in the getLoadContext, useLoaderData is returning
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Error: FOOBAR<br> at ...mycallstack...</pre>
</body>
</html>
For clarity, I'm seeing this in 1.12.0 (where my prod version is running), and I've tested this with the latest 1.14.1-beta.0, same issue.
Thanks for all your help, and keep up the great work!