next.js: Ensure bailed, found path does not match ensure type (pages/app)

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.5.0: Thu Jun  8 22:21:34 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T8112
    Binaries:
      Node: 18.15.0
      npm: 9.5.0
      Yarn: 1.22.19
      pnpm: 7.30.0
    Relevant Packages:
      next: 13.4.14-canary.1
      eslint-config-next: 12.1.5
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: N/A

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

CLI (create-next-app)

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

https://codesandbox.io/p/sandbox/lucid-roentgen-mc8x5s?file=%2Fapp%2Fpage.tsx%3A8%2C1

To Reproduce

  • Customize an interface under pages/api
  • The interface is repeatedly requested on the page, and there is a certain probability of wrong capture

Describe the Bug

image

Expected Behavior

Errors should not be thrown, let alone accidentally

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

NEXT-1603

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 36
  • Comments: 30 (4 by maintainers)

Commits related to this issue

Most upvoted comments

This is being worked on already. @wyattjoh is wrapping up a few test failures around the changes to fix it.

Experiencing the same issue with Next 13.4.13 in dev mode. Haven’t tried on a release build, but I believe this started happening when I upgraded from 13.3 Edit: Downgraded to 13.4.11 and it got solved, so the bug must have been introduced in 13.4.12

Can confirm both 13.4.12 and canary of 13.4.20 has fixed this for me.

I just attempted to upgrade from 13.4.12 to 13.4.19 via yarn upgrade and encountered this issue. I then tried deleting my yarn.lock file and running yarn install as there was a comment above about trashing your package-lock.json file but this also proved fruitless. I am not using the /app directory in my install – my current implementation strictly uses /pages

We lost an entire day to this, pls fix

Upgraded to 13.4.15 and continue to get this issue:

"err":{"name":"Error","source":"server","message":"Ensure bailed, found path does not match ensure type (pages/app)","stack":"Error: Ensure bailed, found path does not match ensure type (pages/app)\n at ensurePageImpl (/home/user/Documents/software/workspace/project/node_modules/next/dist/server/dev/on-demand-entry-handler.js:483:23)"

The issue happens when rendering pages from the pages directory and stops application requests. The pages make API calls to pages/api and issue is causing an internal server 500 error.

If can please provide which version to revert to that does not have this error? Tried 13.4.12 and continues to happen. Primary objective at this point is can use latest version that does not have this error so continue development without having requests fail.

Any idea on why error happens and possible work around until it gets resolved? Is this related to the new App directory not working with legacy pages/api requests? Only using pages/api requests at moment because app/API requests are not working with the PINO logger (which we switched to based on the recommendation on your website).

Thank you.

v13.5.4 fixes the issue I described here

That did not solve the issue for me, i am using next.js 13.4.19.

Facing the same issue. Tried on v13.4.12 and 13.4.19. I get this error on refresh.

Adding my name to the list of those affected on 13.4.19 which see that it’s fixed by reverting down to 13.4.12. I’m also exclusively using the pages directory, no app migration performed yet.

@timneutkens is the provided reproduction sufficient? This is a frequent enough issue that I’ve now thought there were client code issues multiple times when it was this bug rearing its head.

Same issue here. Started after I upgraded from 13.4.12 to 13.4.16. Also happens with 13.4.19. My app requests an api route 14 times using async.map (parallel requests) and gets 1-5 of these errors each time. I just downgraded to 13.4.12 and the problem went away. No need to delete yarn.lock in my case.

Narrowed it down to 13.4.13. Perhaps it was caused by https://github.com/vercel/next.js/pull/53582

Thank you for working on this, can you please provide a NextJS version we can use while we wait for the fix to be available? This issue is causing requests to fail which is impacting development progress. Any insight on what version of NextJS to revert to would be greatly appreciated.

Thank you.