#Endless hydration error loop with latest version of @remix-run/express

1 messages · Page 1 of 1 (latest)

frozen cypress
#

I originally posted this on the GitHub discussion forum yesterday ( https://github.com/remix-run/remix/discussions/9995 ), but then realized this morning that Discord seems to have effectively replaced that medium.

So I was at 2.9.1 of all Remix components. @remix-run/express depends on express, which was at 4.19.2. All was well. Some security vulnerabilities appeared in npm audit, all of which were dependent modules of express (send, body-parser, path-to-regexp). I updated express by itself to 4.21.0. npm audit passed fine then, and my app still worked fine.

Then I updated the @remix-run/node and @remix-run/react components to 2.12.0. All was still well with my app. The @remix-run/express component still was using @remix-run/[email protected] at this point, however.

Lastly, I updated @remix-run/express, and that's when my app got into an endless loop at startup with this error on the dev console:
Initial URL (undefined) does not match URL at time of hydration (/), reloading page...

What changes between @remix-run/express 2.9.1 and 2.12.0 might require changes in my code? The only function I use from that package directly is in my express startup script, which calls createRequestHandler() like so:

function getRequestHandler(build) { function getLoadContext(_, res) { return { cspNonce: res.locals.cspNonce } } return createRequestHandler({ build, mode: MODE, getLoadContext }) }

GitHub

So I was at 2.9.1 of all Remix components. @remix-run/express depends on express, which was at 4.19.2. All was well. Some security vulnerabilities appeared in npm audit, all of which were dependent...

frozen cypress
#

I reverted @remix-run/express (and thus its version of @remix-run/node) to 2.11.2, and no infinite loop.

Another interesting bit is that 2.12.0 never calls my entry.server.tsx handleRequest() function (put a console.log in there as the first line, but it never prints), but does render the requested pages (over and over and over). 2.11.2 still calls my handleRequest().

I also noticed there is a change in the 2.12.0 change log that mentions hydration URL checking and endless looping (see screenshot). So I'd bet money this is related to that change.

So for now I can at least upgrade all Remix components as far as 2.11.2, and that's good enough for now.