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

Custom server + App router doesn't run in dev mode #55278

Closed
1 task done
coltonehrman opened this issue Sep 12, 2023 · 11 comments
Closed
1 task done

Custom server + App router doesn't run in dev mode #55278

coltonehrman opened this issue Sep 12, 2023 · 11 comments
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked Output (export/standalone) Related to the the output option in `next.config.js`.

Comments

@coltonehrman
Copy link
Contributor

coltonehrman commented Sep 12, 2023

Link to the code that reproduces this issue or a replay of the bug

https://app.replay.io/recording/untitled--434d663c-8bfa-4630-9489-80ca45309b22

To Reproduce

  1. npx create-next-app@latest
  2. Install canary npm i next@canary
  3. Add custom server (https://nextjs.org/docs/pages/building-your-application/configuring/custom-server)
  4. Switch dev script to use node server.js
  5. Run npm run dev

Current vs. Expected behavior

App should work.

What happens?

❯ npm run dev

> my-app@0.1.0 dev
> node server.js

 ✓ ready
> Ready on http://localhost:3000
 ○ compiling /page ...
 X Error: Cannot find module 'react-server-dom-webpack/client.edge'
Require stack:
- /Users/cehrman/WebPlatform/my-app/node_modules/next/dist/build/webpack/plugins/nextjs-require-cache-hot-reloader.js
- /Users/cehrman/WebPlatform/my-app/node_modules/next/dist/server/lib/router-utils/setup-dev.js
- /Users/cehrman/WebPlatform/my-app/node_modules/next/dist/server/lib/router-server.js
- /Users/cehrman/WebPlatform/my-app/node_modules/next/dist/server/lib/start-server.js
- /Users/cehrman/WebPlatform/my-app/node_modules/next/dist/server/next.js
- /Users/cehrman/WebPlatform/my-app/server.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1028:15)
    at /Users/cehrman/WebPlatform/my-app/node_modules/next/dist/server/require-hook.js:16:36
    at Function.resolve (node:internal/modules/cjs/helpers:114:19)
    at deleteAppClientCache (/Users/cehrman/WebPlatform/my-app/node_modules/next/dist/build/webpack/plugins/nextjs-require-cache-hot-reloader.js:51:41)
    at /Users/cehrman/WebPlatform/my-app/node_modules/next/dist/build/webpack/plugins/nextjs-require-cache-hot-reloader.js:117:17
    at Hook.eval [as callAsync] (eval at create (/Users/cehrman/WebPlatform/my-app/node_modules/next/dist/compiled/webpack/bundle5.js:13:28867), <anonymous>:21:17)
    at /Users/cehrman/WebPlatform/my-app/node_modules/next/dist/compiled/webpack/bundle5.js:28:144800
    at /Users/cehrman/WebPlatform/my-app/node_modules/next/dist/compiled/neo-async/async.js:1:9372
    at done (/Users/cehrman/WebPlatform/my-app/node_modules/next/dist/compiled/neo-async/async.js:1:14788)
    at Hook.eval [as callAsync] (eval at create (/Users/cehrman/WebPlatform/my-app/node_modules/next/dist/compiled/webpack/bundle5.js:13:28867), <anonymous>:15:1)
    at /Users/cehrman/WebPlatform/my-app/node_modules/next/dist/compiled/webpack/bundle5.js:28:143189
    at /Users/cehrman/WebPlatform/my-app/node_modules/next/dist/compiled/webpack/bundle5.js:1:268008
    at /Users/cehrman/WebPlatform/my-app/node_modules/graceful-fs/graceful-fs.js:61:14
    at FSReqCallback.oncomplete (node:fs:192:23) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/cehrman/WebPlatform/my-app/node_modules/next/dist/build/webpack/plugins/nextjs-require-cache-hot-reloader.js',
    '/Users/cehrman/WebPlatform/my-app/node_modules/next/dist/server/lib/router-utils/setup-dev.js',
    '/Users/cehrman/WebPlatform/my-app/node_modules/next/dist/server/lib/router-server.js',
    '/Users/cehrman/WebPlatform/my-app/node_modules/next/dist/server/lib/start-server.js',
    '/Users/cehrman/WebPlatform/my-app/node_modules/next/dist/server/next.js',
    '/Users/cehrman/WebPlatform/my-app/server.js'
  ]
}

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 22.6.0: Wed Jul  5 22:21:53 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6020
Binaries:
  Node: 16.20.1
  npm: 8.19.4
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 13.4.20-canary.25
  eslint-config-next: 13.4.19
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

App Router, Standalone mode (output: "standalone")

Additional context

Seems to be related to this PR #54813

NEXT-1612

@coltonehrman coltonehrman added the bug Issue was opened via the bug report template. label Sep 12, 2023
@github-actions github-actions bot added the Output (export/standalone) Related to the the output option in `next.config.js`. label Sep 12, 2023
@coltonehrman
Copy link
Contributor Author

Is custom server a thing with the App router? Based on the docs, I do not see any reference to custom server under the App router section. However, I do see it under the Pages router section.

Screenshot 2023-09-12 at 10 47 31 AM

@timneutkens

@fedetorre
Copy link

Hi @coltonehrman ,

I have the same issue without custom server and latest canary release, rolling back to version 13.4.20-canary.23 and the problem disappear!

Below the stacktrace:

Error: Cannot find module 'react-server-dom-webpack/client.edge'
Require stack:
- /home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/build/webpack/plugins/nextjs-require-cache-hot-reloader.js
- /home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/server/lib/router-utils/setup-dev.js
- /home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/server/lib/router-server.js
- /home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/server/lib/start-server.js
- /home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/cli/next-dev.js
- /home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/lib/commands.js
- /home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/bin/next
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at /home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/server/require-hook.js:16:36
    at Function.resolve (node:internal/modules/cjs/helpers:127:19)
    at deleteAppClientCache (/home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/build/webpack/plugins/nextjs-require-cache-hot-reloader.js:51:41)
    at /home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/build/webpack/plugins/nextjs-require-cache-hot-reloader.js:117:17
    at Hook.eval [as callAsync] (eval at create (/home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/compiled/webpack/bundle5.js:13:28867), <anonymous>:21:17)
    at /home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/compiled/webpack/bundle5.js:28:144800
    at /home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/compiled/neo-async/async.js:1:9372
    at done (/home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/compiled/neo-async/async.js:1:14788)
    at Hook.eval [as callAsync] (eval at create (/home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/compiled/webpack/bundle5.js:13:28867), <anonymous>:15:1)
    at /home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/compiled/webpack/bundle5.js:28:143189
    at /home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/compiled/webpack/bundle5.js:1:268008
    at /home/fede/workspace/selfcommunity/community-pwa/app/node_modules/graceful-fs/graceful-fs.js:61:14
    at FSReqCallback.oncomplete (node:fs:200:23)
    at FSReqCallback.callbackTrampoline (node:internal/async_hooks:130:17) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/build/webpack/plugins/nextjs-require-cache-hot-reloader.js',
    '/home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/server/lib/router-utils/setup-dev.js',
    '/home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/server/lib/router-server.js',
    '/home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/server/lib/start-server.js',
    '/home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/cli/next-dev.js',
    '/home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/lib/commands.js',
    '/home/fede/workspace/selfcommunity/community-pwa/app/node_modules/next/dist/bin/next'
  ]
}

@karlhorky
Copy link
Contributor

karlhorky commented Sep 13, 2023

rolling back to version 13.4.20-canary.23 and the problem disappear!

Indeed, it appears this bug was introduced in next@13.4.20-canary.24

Looking at the release notes, maybe #55226 by @feedthejim (reviewed by @timneutkens) sounds related? cc @ijjk

@karlhorky
Copy link
Contributor

Custom Servers are also broken in production (next build + next start), I get the renderToReadableStream is not a function error (shown as an HTTP 500 status code to users):

[WebServer] TypeError: e.renderToReadableStream is not a function
    at /home/runner/work/courses/courses/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:1:62297
    at NextTracerImpl.trace (/home/runner/work/courses/courses/node_modules/next/dist/server/lib/trace/tracer.js:90:20)
    at O (/home/runner/work/courses/courses/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:1:62251)
    at /home/runner/work/courses/courses/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:1:179058
    at /home/runner/work/courses/courses/node_modules/next/dist/server/lib/trace/tracer.js:159:62
    at /home/runner/work/courses/courses/node_modules/next/dist/server/lib/trace/tracer.js:117:36
    at NoopContextManager.with (/home/runner/work/courses/courses/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7057)
    at ContextAPI.with (/home/runner/work/courses/courses/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:516)
    at NoopTracer.startActiveSpan (/home/runner/work/courses/courses/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18086)
    at ProxyTracer.startActiveSpan (/home/runner/work/courses/courses/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18847)
[WebServer]  ⚠ You have added a custom /_error page without a custom /404 page. This prevents the 404 page from being auto statically optimized.
See here for info: https://nextjs.org/docs/messages/custom-error-no-custom-404
[WebServer] GET / 500 [43]4.286 ms - -
Screenshot 2023-09-13 at 12 37 41

@feedthejim
Copy link
Contributor

This is most likely #54813, we are taking a look!

@balazsorban44 balazsorban44 added the linear: next Confirmed issue that is tracked by the Next.js team. label Sep 13, 2023
@feedthejim
Copy link
Contributor

Does this work in the latest canary? I landed a refactor that should affect this.

@karlhorky
Copy link
Contributor

karlhorky commented Sep 17, 2023

Still broken in latest canary on Releases page (currently next@13.4.20-canary.33)

Error no longer present in latest canary on Releases page (currently next@13.4.20-canary.33) 🎉

@feedthejim
Copy link
Contributor

@karlhorky I can not manage to repro anymore after the latest canary, can you double check and/or share your error?

@karlhorky
Copy link
Contributor

My error, I think next@13.4.20-canary.33 is working after all. I saw an error on Sunday, but I may have tricked myself or tested incorrectly.

Can confirm that next@13.4.20-canary.33 is working 🙌

Updated my post above!

@coltonehrman
Copy link
Contributor Author

Does this work in the latest canary? I landed a refactor that should affect this.

Yup, can confirm also that it is working!
Screenshot 2023-09-18 at 10 07 00 AM
Screenshot 2023-09-18 at 10 07 06 AM

kodiakhq bot pushed a commit that referenced this issue Sep 18, 2023
### What?

Removes Replay.io as a valid reproduction link from our bug template.

### Why?

Based on issues #55181 and #55278 it looks like people are struggling to report the correct thing. Also, without source maps, replays are still harder to use for debugging than an actual code base

Ref: [Slack thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1694608481515339?thread_ts=1694428848.689079&cid=C04DUD7EB1B)
@github-actions
Copy link
Contributor

github-actions bot commented Oct 3, 2023

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot added the locked label Oct 3, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked Output (export/standalone) Related to the the output option in `next.config.js`.
Projects
None yet
Development

No branches or pull requests

6 participants