Files
d342d0b91f Trace cacheHandler and cacheHandlers when using adapters (#94197)
### What?

Add focused production adapter coverage for configured `cacheHandler`
and `cacheHandlers` module graphs in Node `output.assets`, including
transitive helper dependencies and Turbopack `assetsHashes` assertions.

### Why?

Adapter deployments dynamically load configured cache handlers at
runtime. This coverage demonstrates that Node adapter outputs currently
omit those handler files and their transitive dependencies.

### How?

Add an App Router Cache Components fixture using `adapterPath`, both
cache-handler APIs, and a `use cache: remote` route. Its adapter writes
`onBuildComplete` context to disk and the test inspects Node outputs for
each handler and uniquely named helper.

### Verification

- `NEXT_TEST_PREFER_OFFLINE=1 pnpm --filter=next build`
- Expected failure: `NEXT_TEST_PREFER_OFFLINE=1 pnpm test-start-turbo
test/production/app-dir/adapter-cache-handlers/adapter-cache-handlers.test.ts`
(no Node output contains all four handler assets)
- Expected failure: `NEXT_TEST_PREFER_OFFLINE=1 pnpm test-start-webpack
test/production/app-dir/adapter-cache-handlers/adapter-cache-handlers.test.ts`
(same adapter handoff gap)
- `git diff canary --check`
- Not run continuously: `pnpm --filter=next dev` (`EMFILE: too many open
files` occurred after startup in the local watcher)

<!-- NEXT_JS_LLM_PR -->

---------

Co-authored-by: Niklas Mischkulnig <[email protected]>
2026-06-03 12:24:54 +02:00

52 lines
1.4 KiB
TypeScript

import { nextTestSetup } from 'e2e-utils'
import path from 'path'
import type { NextAdapter } from 'next'
describe('adapter-cache-handlers', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('includes configured cache handler dependencies in Node adapter outputs', async () => {
const { outputs }: Parameters<NextAdapter['onBuildComplete']>[0] =
await next.readJSON('build-complete.json')
const nodeOutputs = [
...outputs.pages,
...outputs.pagesApi,
...outputs.appPages,
...outputs.appRoutes,
].filter((output) => output.runtime === 'nodejs')
expect(nodeOutputs.length).toBeGreaterThan(0)
const expectedAssets = [
'incremental-cache-handler.js',
'incremental-cache-helper.js',
'use-cache-handler.js',
'use-cache-helper.js',
]
const output = nodeOutputs.find((candidate) =>
expectedAssets.every((filename) =>
Object.values(candidate.assets).some(
(assetPath) => path.basename(assetPath) === filename
)
)
)
expect(output).toBeDefined()
for (const filename of expectedAssets) {
const assetKey = Object.entries(output!.assets).find(
([, assetPath]) => path.basename(assetPath) === filename
)?.[0]
expect(assetKey).toBeString()
if (process.env.IS_TURBOPACK_TEST) {
expect(output!.assetsHashes[assetKey!]).toBeString()
}
}
})
})