Skip to content
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

After upgrading to Remix 1.12.0: TypeError: Cannot read properties of undefined (reading 'remixRequestHandlerPath') #5428

Closed
1 task done
giopetris opened this issue Feb 11, 2023 · 8 comments
Assignees

Comments

@giopetris
Copy link

What version of Remix are you using?

1.12.0

Are all your remix dependencies & dev-dependencies using the same version?

  • Yes

Steps to Reproduce

I'm not sure how to reproduce this, but this error started after I upgrade remix 1.11.0 to 1.12.0, I tried to reproduce by creating a project from scratch using npx create-remix@latest but it worked fine.

Expected Behavior

Run the remix app.

Actual Behavior

It is crashing with the error:

TypeError: Cannot read properties of undefined (reading 'remixRequestHandlerPath')
    at requestHandler (/dashboard/node_modules/@remix-run/server-runtime/dist/server.js:38:94)
    at /dashboard/node_modules/@remix-run/express/dist/server.js:39:28
    at /dashboard/node_modules/@remix-run/serve/dist/index.js:47:7
    at Layer.handle [as handle_request] (/dashboard/node_modules/express/lib/router/layer.js:95:5)
    at next (/dashboard/node_modules/express/lib/router/route.js:144:13)
    at next (/dashboard/node_modules/express/lib/router/route.js:140:7)
    at next (/dashboard/node_modules/express/lib/router/route.js:140:7)
    at next (/dashboard/node_modules/express/lib/router/route.js:140:7)
    at next (/dashboard/node_modules/express/lib/router/route.js:140:7)
    at next (/dashboard/node_modules/express/lib/router/route.js:140:7)

This is my remix.config.js:

/** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
  ignoredRouteFiles: ["**/.*"],
  future: {
    v2_routeConvention: true,
  },
};

After digging a bit, I changed my remix.config.js to the following, the error stopped happening, but, got a new one 😅 :

/** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
  ignoredRouteFiles: ["**/.*"],
  future: {
    v2_routeConvention: true,
    unstable_dev: { remixRequestHandlerPath: "" }, // <--- Added this line
  },
};

Now my browser shows Upgrade Required:
CleanShot 2023-02-11 at 11 01 04@2x

Nothing on the terminal.

@pcattori pcattori self-assigned this Feb 13, 2023
@alexblack
Copy link

I'm hitting this too, trying to upgrade from 1.8.2 -> 1.13.0

[1] TypeError: Cannot read properties of undefined (reading 'remixRequestHandlerPath')
[1]     at requestHandler (/Users/alex/dev/micro/webapp/node_modules/@remix-run/server-runtime/dist/server.js:38:94)
[1]     at /Users/alex/dev/micro/webapp/node_modules/@remix-run/express/dist/server.js:39:28
[1]     at /Users/alex/dev/micro/webapp/node_modules/@sentry/src/utils/serverAdapters/express.ts:85:1

@alexblack
Copy link

alexblack commented Feb 17, 2023

Adding this line:

module.exports = {
  future: {
    unstable_dev: { remixRequestHandlerPath: "" }, // <--- Added this line
  },
};

Didn't seem to help me, no change.

@alexblack
Copy link

ah its this line:

if (mode$1 === "development" && unstable_dev !== false && url.pathname === (unstable_dev.remixRequestHandlerPath ?? "") + "/__REMIX_ASSETS_MANIFEST") {

If I change it to:

if (mode$1 === "development" && unstable_dev !== false && url.pathname === (unstable_dev?.remixRequestHandlerPath ?? "") + "/__REMIX_ASSETS_MANIFEST") {

Then it works

@pcattori
Copy link
Contributor

pcattori commented Feb 17, 2023

Culprit is here:

future: FutureConfig;

Should have been:

  future?: FutureConfig;

Symptom of the duplicated types we have across packages.

The future property is intentionally required, because its already resolved for the server build (it should only be optional as input taken from the Remix config).

This seems to be caused by a successful browser build but unsuccessful server build, but since you already had a server build prior, the old server build is used. So there's a mismatch where the browser build could be on v1.13 and the server build could be on your previous version e.g. 1.8

To fix, you can run remix build and fix all the errors there and then run remix dev and see if that fixes it.
We need to do a better job of surfacing the errors during remix dev, but I don't think this is actually related to future or unstable_dev.

Might already be fixed by #5441

@pcattori
Copy link
Contributor

pcattori commented Feb 21, 2023

From @brophdawg11 on discord:

Ah thank you for this additional context @derekxw! This lack of build errors was fixed in #5441 but I don't think it had been made apparent that this could be an underlying cause of these Cannot read properties of undefined (reading 'v2_errorBoundary') errors.

For anyone else running into this issue in the future - please run remix build after upgrading all remix dependencies and see if it surfaces any build errors. The merged fix to also ensure these errors show during remix dev should be released in 1.14.0

Also from @brophdawg11 on discord:

This usually comes down to one of 2 issues: (1) not all of your remix deps are on the same version or (2) one of your builds is failing and it's not getting logged properly by npm run dev. There's more context in this thread: https://discord.com/channels/770287896669978684/1067867784161263686/1075162483028926568

@pcattori pcattori reopened this Feb 21, 2023
@brophdawg11
Copy link
Contributor

👍 I'm almost positive this is just a mismatched dependency/build issue which is why it only happened when upgrading from 1.11.0 -> 1.12.0 but is not reproducible on a fresh 1.12.0 install. With the enhanced logging being released in 1.14.0 the underlying cause of these build issues should be better surfaced when running remix dev.

@pcattori
Copy link
Contributor

Closing as this should have been addressed by #5441 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants