Files
next.js/test/e2e/app-dir/with-exported-function-config/with-exported-function-config.test.ts
Jiwon ChoiandGitHub 9150f1b78b fix(next): properly pass layout-level maxDuration config to the children page segments on build (#68793)
> [!NOTE]
> This PR is recommended to [hide
whitespace](https://github.blog/news-insights/product-news/ignore-white-space-in-code-review/)
when reviewing.

### What?

Fixed layouts to properly pass route segment config `maxDuration` to
their children page segments.

```tsx
// layout.tsx

export const maxDuration = 5

```

### Why?

- We separately handle the route segment configs on different places.
- `maxDuration` was missing logic to get value from the layouts unlike
[other route segment
configs](https://github.com/vercel/next.js/blob/canary/packages/next/src/build/utils.ts#L1636-L1652).

### How?

- Instead of explicit logic for the `maxDuration`, get the route segment
configs from the layout on the page's static info.
- Ensure to inherit the value from the layout only if is a page segment.

#### See Changes by Commits

- current: 522b9537d5d249e39e606f4f69459ac9f9519ded
- expected: 12496d445703bb23dc4beb14ed13dcbec458a539
- fix: 196e0e86ee11b9319c899123e16d3a632dbbe37c

Fixes NDX-196
2024-08-15 19:07:27 +09:00

49 lines
1.1 KiB
TypeScript

import { nextTestSetup } from 'e2e-utils'
describe('with-exported-function-config', () => {
const { next, isNextStart } = nextTestSetup({
files: __dirname,
})
it('should have correct values in function config manifest', async () => {
if (isNextStart) {
const functionsConfigManifest = JSON.parse(
await next.readFile('.next/server/functions-config-manifest.json')
)
expect(functionsConfigManifest).toEqual({
functions: {
'/api/page-route': {
maxDuration: 1,
},
'/app-layout': {
maxDuration: 1,
},
'/app-layout/inner': {
maxDuration: 2,
},
'/app-route': {
maxDuration: 1,
},
'/app-route-edge': {
maxDuration: 2,
},
'/app-ssr': {
maxDuration: 3,
},
'/app-ssr-edge': {
maxDuration: 4,
},
'/page': {
maxDuration: 2,
},
'/page-ssr': {
maxDuration: 3,
},
},
version: 1,
})
}
})
})