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

Emit build error for unknown cache kinds #72832

Merged
merged 8 commits into from
Nov 17, 2024

Conversation

unstubbable
Copy link
Contributor

@unstubbable unstubbable commented Nov 14, 2024

When a "use cache" directive with a custom cache kind is used, e.g. "use cache: custom", a cache handler with the same name must be specified in the Next.js config:

/**
 * @type {import('next').NextConfig}
 */
const nextConfig = {
  experimental: {
    dynamicIO: true,
    cacheHandlers: {
      custom: require.resolve('path/to/custom/cache/handler'),
    },
  },
}

module.exports = nextConfig

If this is not the case, we emit a build error with an error message that explains this requirement.

Screenshot 2024-11-14 at 23 30 01

When we'll get a docs page for this experimental config, we will add the usual "Read more: ..." hint as well.

Copy link
Contributor Author

unstubbable commented Nov 14, 2024

@unstubbable unstubbable changed the title Rename in_cache_file to file_cache_type Emit build error for unknown cache kinds Nov 14, 2024
@ijjk
Copy link
Member

ijjk commented Nov 14, 2024

Tests Passed

@unstubbable unstubbable force-pushed the hl/error-for-unknown-cache-handlers branch from 2d51b87 to 301baaf Compare November 14, 2024 22:33
@unstubbable unstubbable marked this pull request as ready for review November 14, 2024 22:33
@unstubbable unstubbable force-pushed the hl/refactor-server-actions-transforms-errors branch from df920a0 to 5bda6e6 Compare November 14, 2024 23:04
@unstubbable unstubbable force-pushed the hl/error-for-unknown-cache-handlers branch from 301baaf to 18eaec2 Compare November 14, 2024 23:04
@bgw
Copy link
Member

bgw commented Nov 15, 2024

Here's my suggested rust changes: 10e487a

  • Some stuff to reduce cloning
  • Pull RcStr into next-custom-transforms and use it across the config + transform
  • Use a BodyInfo named struct for get_body_info instead of returning a less-obvious tuple type (not this PR's fault, but this PR touches it a lot).

Otherwise the Rust code LGTM.

@unstubbable unstubbable changed the base branch from hl/refactor-server-actions-transforms-errors to graphite-base/72832 November 15, 2024 12:55
@unstubbable unstubbable force-pushed the hl/error-for-unknown-cache-handlers branch from e591b8c to bb08f94 Compare November 15, 2024 12:55
@unstubbable unstubbable changed the base branch from graphite-base/72832 to canary November 15, 2024 12:56
@unstubbable unstubbable force-pushed the hl/error-for-unknown-cache-handlers branch from bb08f94 to 633d34f Compare November 15, 2024 12:56
@unstubbable unstubbable force-pushed the hl/error-for-unknown-cache-handlers branch from acdafab to 021b157 Compare November 16, 2024 10:52
unstubbable and others added 4 commits November 16, 2024 12:51
When a `"use cache"` directive with a custom cache kind is used, e.g.
`"use cache: custom"`, a cache handler with the same name must be
specified in the Next.js config:

```js
/**
 * @type {import('next').NextConfig}
 */
const nextConfig = {
  experimental: {
    dynamicIO: true,
    cacheHandlers: {
      custom: require.resolve('path/to/custom/cache/handler'),
    },
  },
}

module.exports = nextConfig
```

If this is not the case, we emit a build error with an error message
that explains this requirement.

When we'll get a docs page for this experimental config, we will add
the usual "Read more: ..." hint as well.
@unstubbable unstubbable force-pushed the hl/error-for-unknown-cache-handlers branch from 021b157 to 2adf9e7 Compare November 16, 2024 11:51
@unstubbable unstubbable merged commit d54122a into canary Nov 17, 2024
106 of 110 checks passed
@unstubbable unstubbable deleted the hl/error-for-unknown-cache-handlers branch November 17, 2024 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
created-by: Next.js team PRs by the Next.js team. tests Turbopack Related to Turbopack with Next.js. type: next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants