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

Bug: appDir applications can have dataRoute: null #1940

Closed
Skn0tt opened this issue Feb 24, 2023 · 27 comments · Fixed by #2018 or #2041
Closed

Bug: appDir applications can have dataRoute: null #1940

Skn0tt opened this issue Feb 24, 2023 · 27 comments · Fixed by #2018 or #2041
Assignees
Labels
Ecosystem: Frameworks priority: high type: bug code to address defects in shipped code

Comments

@Skn0tt
Copy link
Member

Skn0tt commented Feb 24, 2023

When you run next build on https://github.com/redmonkez12/interactive-rating-component/tree/079f65a9b1d84efe2c1032dc01c022b46a7c0fb5, then prerender-manifest.json will contain

"/api/hello": {
    "initialHeaders": { "content-type": "text/plain;charset=UTF-8" },
    "initialRevalidateSeconds": false,
    "srcRoute": "/api/hello",
    "dataRoute": null
  }

Our runtime currently can't handle that, and will throw an error here, because dataRoute is null:

.filter(([, { dataRoute }]) => dataRoute.endsWith('.rsc'))

To fix that, we should update the Next.js version that this repo is pulling TS types from, and fix all places where the types now fail.

@MarcL MarcL added type: bug code to address defects in shipped code priority: high Ecosystem: Frameworks labels Feb 24, 2023
@MarcL
Copy link
Contributor

MarcL commented Feb 24, 2023

Feels like this is a high priority so I've added it to the current iteration as an "up next".

@voyagebagage
Copy link

voyagebagage commented Mar 16, 2023

When you run next build on https://github.com/redmonkez12/interactive-rating-component/tree/079f65a9b1d84efe2c1032dc01c022b46a7c0fb5, then prerender-manifest.json will contain

"/api/hello": {
    "initialHeaders": { "content-type": "text/plain;charset=UTF-8" },
    "initialRevalidateSeconds": false,
    "srcRoute": "/api/hello",
    "dataRoute": null
  }

Our runtime currently can't handle that, and will throw an error here, because dataRoute is null:

.filter(([, { dataRoute }]) => dataRoute.endsWith('.rsc'))

To fix that, we should update the Next.js version that this repo is pulling TS types from, and fix all places where the types now fail.

so no fix yet right?
I have same problem I have tried to deploy my project at the start without almost any code, just setting tailwind and chakra ui on Next13 last version but the deploy is failing the same way

REPO

I don't know if any relation, but whenever I put an UI to Next13 I have an hydratation error :

hydration-error-info.js?32aa:27 Warning: Extra attributes from the server: cz-shortcut-listen
at body
at html
at RootLayout (webpack-internal:///(app-client)/./app/layout.tsx:37:11)

@nickytonline
Copy link
Contributor

I upgraded to the latest version of Next.js 13.2.4 and these are the types now.

CleanShot 2023-03-27 at 16 04 15

We can definitely upgrade Next.js in the project to get the new types, but the it can be fixed even without that update.

export const getRscDataRouter = ({ routes: staticRoutes, dynamicRoutes }: PrerenderManifest): EdgeFunction => {
  const staticRouteSet = new Set(
    Object.entries(staticRoutes)
-      .filter(([, { dataRoute }]) => dataRoute.endsWith('.rsc'))
+      .filter(([, { dataRoute }]) => dataRoute?.endsWith('.rsc')) 
      .map(([route]) => route),
  )
...

From what I can tell this isn't picked up in the codebase (even with the Next.js update) because it's a file that is copied. See

const edgeFunctionDir = resolve('.netlify', 'edge-functions', 'rsc-data')
await ensureDir(edgeFunctionDir)
await copyEdgeSourceFile({ edgeFunctionDir, file: 'rsc-data.ts' })

I'm going to go ahead and put up a fix for this, and I'll create a separate issue for updating the Next.js version in the repo.

@narbota
Copy link

narbota commented Mar 28, 2023

Hello, I'm getting the same error as well when deploying Nextjs 13 site https://app.netlify.com/sites/next-13-trail/deploys/6423617b0dc578000711a6fe
Internal error during Edge functions budling" 5:53:04 PM: 5. Edge Functions bundling
5:53:04 PM: ────────────────────────────────────────────────────────────────
5:53:04 PM:
5:53:04 PM: Packaging Edge Functions from .netlify/edge-functions directory:
5:53:04 PM: - rsc-data
5:53:05 PM: TypeError: Cannot read properties of null (reading 'endsWith')
5:53:05 PM: at file:///opt/build/repo/.netlify/edge-functions/edge-shared/rsc-data.ts:38:48
5:53:05 PM: at Array.filter ()
5:53:05 PM: at getRscDataRouter (file:///opt/build/repo/.netlify/edge-functions/edge-shared/rsc-data.ts:38:8)
5:53:05 PM: at file:///opt/build/repo/.netlify/edge-functions/rsc-data/rsc-data.ts:4:17
5:53:05 PM: Could not load edge function at '/opt/build/repo/.netlify/edge-functions/rsc-data/rsc-data.ts'
5:53:05 PM:
5:53:05 PM: Internal error during "Edge Functions bundling"
5:53:05 PM: ────────────────────────────────────────────────────────────────
5:53:05 PM:
5:53:05 PM: Error message
5:53:05 PM: TypeError: Expected a string

@nickytonline
Copy link
Contributor

As mentioned in Slack @narbota, we're currently rolling out v. 4.33.0. If they're not auto-installing, they can upgrade to the latest version of the runtime.

@Fox32
Copy link

Fox32 commented Mar 30, 2023

Upgraded to 4.33.0 today, still hitting the same error:

Packaging Edge Functions from .netlify\edge-functions directory:
 - rsc-data
Could not load edge function at 'C:\Users\Oliver\dev\blog\.netlify\edge-functions\rsc-data\rsc-data.ts'
TypeError: Cannot read properties of null (reading 'endsWith')
    at file:///C:/Users/Oliver/dev/blog/.netlify/edge-functions/edge-shared/rsc-data.ts:38:48
    at Array.filter (<anonymous>)
    at getRscDataRouter (file:///C:/Users/Oliver/dev/blog/.netlify/edge-functions/edge-shared/rsc-data.ts:38:8)
    at file:///C:/Users/Oliver/dev/blog/.netlify/edge-functions/rsc-data/rsc-data.ts:4:17

  Internal error during "Edge Functions bundling"
────────────────────────────────────────────────────────────────

  Error message
  TypeError: Expected a string

  Error location
  During Edge Functions bundling
      at module.exports (C:\Users\Oliver\dev\blog\node_modules\glob-to-regexp\index.js:3:11)
      at pathToRegularExpression (file:///C:/Users/Oliver/dev/blog/node_modules/@netlify/edge-bundler/dist/node/manifest.js:67:31)
      at getRegularExpression (file:///C:/Users/Oliver/dev/blog/node_modules/@netlify/edge-bundler/dist/node/manifest.js:78:12)
      at file:///C:/Users/Oliver/dev/blog/node_modules/@netlify/edge-bundler/dist/node/manifest.js:32:25
      at Array.forEach (<anonymous>)
      at generateManifest (file:///C:/Users/Oliver/dev/blog/node_modules/@netlify/edge-bundler/dist/node/manifest.js:27:18)
      at writeManifest (file:///C:/Users/Oliver/dev/blog/node_modules/@netlify/edge-bundler/dist/node/manifest.js:89:22)
      at bundle (file:///C:/Users/Oliver/dev/blog/node_modules/@netlify/edge-bundler/dist/node/bundler.js:73:28)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async coreStep (file:///C:/Users/Oliver/dev/blog/node_modules/@netlify/build/lib/plugins_core/edge_functions/index.js:35:30)

@nickytonline
Copy link
Contributor

@Fox32, apologies, but I mispoke. This fix didn't roll out in v. 4.33.0. I'm adding it to the next release.

@ghost
Copy link

ghost commented Apr 3, 2023

Hi there, I've been trying unsuccessfully to deploy Next (v13.2.4) with experimental appDir: true BUT with no edge functions at all. It's way impossible having this up and running, nevertheless my setup works fine locally. Also, a different Github project/repo using a previous version of next (13.1.6) worked like a charm when deployed in Netlify, but with the latest one, after trying and trying different workarounds suggested by community users, I keep getting this:

capture-netlify-deploy-fail|690x334

I got nothing fancy, just a fresh nextjs using --typescript... and appDir=true. My dependencies (package.json):

"dependencies": {
"@netlify/plugin-nextjs": "^4.33.0",
"@types/node": "18.15.11",
"@types/react": "18.0.33",
"@types/react-dom": "18.0.11",
"next": "13.2.4",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "5.0.3"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"eslint": "^8.37.0"
}

My next.config.js:

/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
experimental: {
appDir: true,
},
}
module.exports = nextConfig

...it's really frustrating not seeing any advance on this. Thanks in advance

@nickytonline
Copy link
Contributor

@proyectosynergosorg, the fix in #2018 will sort this out. I'm looking to get it merged tomorrow.

@kodiakhq kodiakhq bot closed this as completed in #2018 Apr 4, 2023
@Reniactor
Copy link

Ohhh so it is a bug on NextJs. Hopefully i'll get to try the fix out tomorrow ;-;

Also, is there any easy way to a workaround or something? :>

@kindrift-vt
Copy link

@nickytonline Any movement on the fix? I see #2018 was merged but I'm still running into the same issue on my deploys that have internal errors on edge function bundling. I posted on a thread here: https://answers.netlify.com/t/next-app-edge-function-bundling-error/89530

@Reniactor
Copy link

@kindrift-vt i honestly just used vercel page to deploy the app and it's working perfectly. Didn't have this issue there

@nickytonline
Copy link
Contributor

This is fixed and will start rolling out next week @kindrift-vt.

@vst
Copy link

vst commented Apr 11, 2023

For the record: with Next.js v13.2, removing /api directory allowed us to deploy the app Netlify. With Next.js v13.3, this approach no longer works.

@myko1328
Copy link

hey @nickytonline . I've installed the latest update ("@netlify/plugin-nextjs": "^4.34.0") but encountered another error.

Screenshot_107

@nickytonline
Copy link
Contributor

nickytonline commented Apr 11, 2023

hey @nickytonline . I've installed the latest update ("@netlify/plugin-nextjs": "^4.34.0") but encountered another error.

@myko1328, this error seems unrelated to the original issue. Mind creating a separate issue for this?

@kindrift-vt
Copy link

hey @nickytonline . I've installed the latest update ("@netlify/plugin-nextjs": "^4.34.0") but encountered another error.

@myko1328, this error seems unrelated to the original issue. Mind creating a separate issue for this?

Can confirm that @myko1328's error now occurs. this might be related in the sense that the error only surfaced after the fix. Should I make a new issue linking to this?

@kindrift-vt
Copy link

For the record: with Next.js v13.2, removing /api directory allowed us to deploy the app Netlify. With Next.js v13.3, this approach no longer works.

Did you remove the api directory altogether or remove them from either the /app or /pages dir?

@vst
Copy link

vst commented Apr 12, 2023

For the record: with Next.js v13.2, removing /api directory allowed us to deploy the app Netlify. With Next.js v13.3, this approach no longer works.

Did you remove the api directory altogether or remove them from either the /app or /pages dir?

I removed the api directory altogether. This is how I managed to build before v13.3.

@kindrift-vt
Copy link

For the record: with Next.js v13.2, removing /api directory allowed us to deploy the app Netlify. With Next.js v13.3, this approach no longer works.

Did you remove the api directory altogether or remove them from either the /app or /pages dir?

I removed the api directory altogether. This is how I managed to build before v13.3.

I removed the api directory. Didn't work. But that might be because there can be a new bug?

@Maxservais
Copy link

Also facing the same issue
image

@jonverne1
Copy link

Same error message as above using the latest versions of Next and the plugin. My Project is created via create-next-app with the appDir. Otherwise I haven't made any other major changes. Runs fine locally.

@miketalley
Copy link

Hello, I am experiencing this issue as well. I'm also using appDir on a project creates with create-next-app.

  5. Edge Functions bundling                                    
────────────────────────────────────────────────────────────────

Packaging Edge Functions from .netlify/edge-functions directory:
 - rsc-data

Packaging Edge Functions from netlify/edge-functions directory:
 - hello
Local version of types is up-to-date: 643581608391e3000851cc94
No globalVersion or semver not satisfied. globalVersion: undefined, versionRange: ^1.22.0
Using cached Deno CLI from /Users/miketalley/Library/Preferences/netlify/deno-cli/deno
No globalVersion or semver not satisfied. globalVersion: undefined, versionRange: ^1.22.0
No globalVersion or semver not satisfied. globalVersion: undefined, versionRange: ^1.22.0
Using cached Deno CLI from /Users/miketalley/Library/Preferences/netlify/deno-cli/deno
Using cached Deno CLI from /Users/miketalley/Library/Preferences/netlify/deno-cli/deno
No in-source config found for edge function at '/Users/miketalley/Repos/liblab-lotr/netlify/edge-functions/hello.ts'
TypeError: Cannot read properties of null (reading 'endsWith')
    at file:///Users/miketalley/Repos/liblab-lotr/.netlify/edge-functions/edge-shared/rsc-data.ts:38:48
    at Array.filter (<anonymous>)
    at getRscDataRouter (file:///Users/miketalley/Repos/liblab-lotr/.netlify/edge-functions/edge-shared/rsc-data.ts:38:8)
    at file:///Users/miketalley/Repos/liblab-lotr/.netlify/edge-functions/rsc-data/rsc-data.ts:4:17
Could not load edge function at '/Users/miketalley/Repos/liblab-lotr/.netlify/edge-functions/rsc-data/rsc-data.ts'

  Internal error during "Edge Functions bundling"               
────────────────────────────────────────────────────────────────

  Error message
  TypeError: Expected a string

  Error location
  During Edge Functions bundling
      at module.exports (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/node_modules/glob-to-regexp/index.js:3:11)
      at pathToRegularExpression (file:///usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/manifest.js:94:31)
      at getRegularExpression (file:///usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/manifest.js:115:12)
      at file:///usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/manifest.js:60:25
      at Array.forEach (<anonymous>)
      at generateManifest (file:///usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/manifest.js:55:18)
      at writeManifest (file:///usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/manifest.js:136:22)
      at bundle (file:///usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/bundler.js:78:28)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async coreStep (file:///usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/build/lib/plugins_core/edge_functions/index.js:35:30)

@nickytonline
Copy link
Contributor

@miketalley an others, the fix for this is in the latest version of the Next.js runtime, 4.34.0. Is that the version of the Next.js runtime you see in your logs @miketalley?

@miketalley
Copy link

Yes

2:12:10 PM: ❯ Using Next.js Runtime - v4.34.0

@jonverne1
Copy link

Screenshot 2023-04-13 at 11 52 20 AM
Screenshot 2023-04-13 at 11 51 50 AM
Here is the output of the build log in Netlify. I have your plugin locked at v4.34.0 in my dev dependencies and Next@13.3

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