vercel / next.js

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

`maxDuration` not honored for pages defining parallel routes #63072

Open spencerwilson opened 8 months ago

spencerwilson commented 8 months ago

Link to the code that reproduces this issue

https://github.com/spencerwilson/nextjs-maxDuration-repro

To Reproduce

  1. Run npm run build on https://github.com/spencerwilson/nextjs-maxDuration-repro/commit/c6a491b4e71bec9b98b22184e970526cab640adb and observe:
    $ jq . .next/server/functions-config-manifest.json
    {
    "version": 1,
    "functions": {
    "/": {
      "maxDuration": 6
    }
    }
    }
  2. Run npm run build on https://github.com/spencerwilson/nextjs-maxDuration-repro/commit/1b5f8ee4fded20e0abac6afcf1d3c58d2e249760 and observe:
    $ jq . .next/server/functions-config-manifest.json
    {
    "version": 1,
    "functions": {}
    }

The difference between those two revisions - diff - is that the index page's maxDuration stops being reported in this build output when the filesystem includes at least one parallel route slot in a page's directory. In this case I added an app/@other/ slot.

Current vs. Expected behavior

As far as I can tell there are no docs, on https://nextjs.org/docs/app/building-your-application/routing/parallel-routes or elsewhere, describing any coupling between a) parallel routes, and b) maxDuration. Therefore, I expected that maxDuration would always be emitted, even if the page is using parallel routes.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 18.19.1
  npm: 10.2.4
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.0-canary.10 // Latest available version is detected (14.2.0-canary.10).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A

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

Not sure, App Router

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

next build (local), Vercel (Deployed)

Additional context

I'm new to Next.js so have no idea what canary release might have introduced this.

This issue came to my attention when I observed that my attempts to use maxDuration to increase my hosting platform's timeout were not having an effect. In the repro example, honoring maxDuration would mean a 6-second timeout, but my hosting platform (Vercel) observed 10 s still:

image

I'm not 100% sure in the relevance of .next/server/functions-config-manifest.json , but it does perfectly correlate with my hosting platform doing what I expect to w/ the next build output—or not doing what I expect, as the case may be.

If this is expected behavior for some subtle technical reason, please consider updating the Next.js docs to explain how using parallel routes is expected to affect any route segment config such as maxDuration. Thank you!

kennethlng commented 2 weeks ago

Are there any updates regarding this issue? I'm running into the same issue (using 14.2.12).

Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!