Skip to content

Conversation

@H01001000
Copy link
Contributor

This PR fixes the docs' example where it used class (like cacheHandler (no s)), but cacheHandlers expect an object.

@ijjk ijjk added the Documentation Related to Next.js' official documentation. label Nov 12, 2025
@ijjk
Copy link
Member

ijjk commented Nov 12, 2025

Allow CI Workflow Run

  • approve CI run for commit: 792680d

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

Comment on lines 336 to 339
module.exports = {
constructor() {
this.client = createClient({ url: process.env.REDIS_URL })
this.client.connect()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The object literal syntax doesn't support constructor methods like classes do. When converting from a class to an object, the Redis client initialization needs to be moved outside the exported object. Consider restructuring like this:

const { createClient } = require('redis')
const client = createClient({ url: process.env.REDIS_URL })
client.connect()

module.exports = {
  // Methods that use client
  async get(cacheKey, softTags) {
    // Implementation using client
  },
  // Other methods...
}

This ensures the Redis client is properly initialized before the module is exported and can be used by the handler methods.

Suggested change
module.exports = {
constructor() {
this.client = createClient({ url: process.env.REDIS_URL })
this.client.connect()
const { createClient } = require('redis')
const client = createClient({ url: process.env.REDIS_URL })
client.connect()
module.exports = {

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@H01001000 H01001000 mentioned this pull request Nov 17, 2025
Copy link
Collaborator

@icyJoseph icyJoseph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, and come to think I actually answered an issue about this with the right info... 🤦 it happens

@icyJoseph icyJoseph enabled auto-merge (squash) November 18, 2025 11:27
@icyJoseph icyJoseph merged commit d174698 into vercel:canary Nov 18, 2025
62 checks passed
Moroshima pushed a commit to Moroshima/next.js that referenced this pull request Nov 20, 2025
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

This PR fixes the docs' example where it used class (like cacheHandler
(no s)), but cacheHandlers expect an object.

---------

Co-authored-by: Joseph <[email protected]>
@github-actions github-actions bot added the locked label Dec 2, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 2, 2025
@H01001000 H01001000 deleted the docs/fix-cacheHandlers-type branch December 5, 2025 01:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Documentation Related to Next.js' official documentation. locked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants