vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.54k stars 26.82k forks source link

Router evaluation failed: received error from javascript stream #50075

Open jb-thery opened 1 year ago

jb-thery commented 1 year ago

Verify canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.4.0: Mon Mar  6 20:59:58 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6020
    Binaries:
      Node: 18.16.0
      npm: 9.5.1
      Yarn: N/A
      pnpm: 7.15.0
    Relevant packages:
      next: 13.4.3
      eslint-config-next: 13.4.2
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.0.4

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

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

https://github.com/jb-thery/turbo-repo-next-turbo-pack-issue

To Reproduce

Create a basic turbo repo with pnpm

pnpm dlx create-turbo@latest

Add --turbo ti nex dev script in web app directory

Describe the Bug

I have this issue when i add --turbo flag on dev server script :

error during Next.js routing for /

Caused by:
- router evaluation failed: received error from javascript stream
- could not find app asset

Debug info:
- Execution of get_from_source failed
- Execution of resolve_source_request failed
- Execution of NextRouterContentSource::get failed
- error during Next.js routing for /
- router evaluation failed: received error from javascript stream
- Execution of get_evaluate_pool failed
- Execution of emit failed
- Execution of internal_assets failed
- Execution of separate_assets failed
- Execution of primary_referenced_assets failed
- Execution of NodeJsBootstrapAsset::references failed
- Execution of DevChunkingContext::evaluated_chunk_group failed
- Execution of EcmascriptChunk::parallel_chunks failed
- Execution of ecmascript_chunk_content_single_entry failed
- Execution of DevChunkingContext::can_be_in_same_chunk failed
- Execution of turbopack_core::ident::AssetIdentVc::path failed
- Execution of turbopack_core::ident::AssetIdentVc::with_modifier failed
- Execution of route_bootstrap failed
- could not find app asset

or

Error: Cannot find module 'next/dist/server/node-polyfill-fetch'

Debug info:
- Error: Cannot find module 'next/dist/server/node-polyfill-fetch'
      [at /Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_polyfill_app-polyfills.ts_831689._.js:14:15]
      [at Object.<anonymous> (/Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_polyfill_app-polyfills.ts_831689._.js:17:3)]
      [at [next]/polyfill/app-polyfills.ts (ecmascript, ssr) (/Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_polyfill_app-polyfills.ts_831689._.js:35:3)]
      [at /Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_entry_app-renderer.tsx_0eb918._.js:496:21]
      [at runModuleExecutionHooks (/Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_entry_app-renderer.tsx_0eb918._.js:542:3)]
      [at instantiateModule (/Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_entry_app-renderer.tsx_0eb918._.js:494:3)]
      [at getOrInstantiateModuleFromParent (/Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_entry_app-renderer.tsx_0eb918._.js:587:10)]
      [at esmImport (/Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_entry_app-renderer.tsx_0eb918._.js:217:18)]
      [at /Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_entry_app-renderer.tsx_51c017._.js:27:109]
      [at [next]/entry/app-renderer.tsx/(COMPONENT_0)/[project]/app/page.tsx (ecmascript, client chunks)/(COMPONENT_1)/[project]/app/layout.tsx (ecmascript, client chunks)/(BOOTSTRAP)/[next]/entry/app/hydrate.tsx (ecmascript, chunk group files) (ecmascript, ssr) (/Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_entry_app-renderer.tsx_51c017._.js:301:3)]
      [at /Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_entry_app-renderer.tsx_0eb918._.js:496:21]
      [at runModuleExecutionHooks (/Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_entry_app-renderer.tsx_0eb918._.js:542:3)]
      [at instantiateModule (/Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_entry_app-renderer.tsx_0eb918._.js:494:3)]
      [at getOrInstantiateRuntimeModule (/Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_entry_app-renderer.tsx_0eb918._.js:1433:10)]
      [at Object.registerChunk (/Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_entry_app-renderer.tsx_0eb918._.js:1538:11)]
      [at registerChunk (/Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_entry_app-renderer.tsx_0eb918._.js:1497:18)]
      [at <anonymous>]
      [at /Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_entry_app-renderer.tsx_0eb918._.js:1587:18]
      [at Object.<anonymous> (/Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_entry_app-renderer.tsx_0eb918._.js:1588:3)]
      [at Module._compile (node:internal/modules/cjs/loader:1254:14)]
      [at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)]
      [at Module.load (node:internal/modules/cjs/loader:1117:32)]
      [at Module._load (node:internal/modules/cjs/loader:958:12)]
      [at Module.require (node:internal/modules/cjs/loader:1141:19)]
      [at require (node:internal/modules/cjs/helpers:110:18)]
      [at Object.<anonymous> (/Users/jbty/WebstormProjects/labs/test-turbo/apps/web/.next/server/app/chunks/ssr/[next]_entry_app-renderer.tsx_b2ffe0._.js:17:1)]
      [at Module._compile (node:internal/modules/cjs/loader:1254:14)]
      [at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)]
      [at Module.load (node:internal/modules/cjs/loader:1117:32)]
      [at Module._load (node:internal/modules/cjs/loader:958:12)]
      [at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)]
      [at node:internal/main/run_main_module:23:47]

Status: exit status: 0

Expected Behavior

Use turbo pack dev server

Which browser are you using? (if relevant)

Chrome

How are you deploying your application? (if relevant)

Vercel

Artforge commented 1 year ago

I also encountered this issue, but in my case it occurred only when the dynamic route included spaces (or possibly other unusual characters, it had both).

The error payload was a follows

- router evaluation failed: no message received from javascript stream
[500] error (12ms): error during Next.js routing for /artforge/testing/file/8cefdc9676dc7d0d/images/DALL·E 2023-05-18 15.44.08 - A relaxed oxen sitting on a sofa in the style of monet.png

Caused by:
- router evaluation failed: no message received from javascript stream

Debug info:
- Execution of get_from_source failed
- Execution of resolve_source_request failed
- Execution of NextRouterContentSource::get failed
- error during Next.js routing for /artforge/testing/file/8cefdc9676dc7d0d/images/DALL·E 2023-05-18 15.44.08 - A relaxed oxen sitting on a sofa in the style of monet.png
- router evaluation failed: no message received from javascript stream

once I removed the --turbo flag from next dev, it worked as expected

vktrl commented 1 year ago

I had a similar problem in PNPM monorepo which was resolved with adding an undocumented --root path/to/root flag discussed here: https://github.com/vercel/turbo/issues/4763#issuecomment-1531880273.

However, this resulted in a wall of errors related to SSR, seems like it's caused by still resolving the package root as the project root and trying to load stuff from node_modules/.pnpm which doesn't exist:

var nodePreGyp = __turbopack_require__("[project]/node_modules/.pnpm/@mapbox+node-pre-gyp@1.0.10/node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js (ecmascript, rsc)");
joacub commented 1 year ago

same erro here using tubro

hkbertoson commented 1 year ago

I was having this issue as well. Once I removed --turbo from next dev it worked just fine.