vercel / vercel/next.js

Next.js 15 - Unsupported "BinaryExpression" error in "revalidate" field for math expressions

Open
#72,365 6 comments 16 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://github.com/GitDevla/next_my_app

To Reproduce
  1. Create a new Next.js 15 project or use an existing one upgraded to Next.js 15.
  2. Define a revalidate field with a mathematical expression in one of the route handlers. For example:
export const revalidate = 60 * 5;
  1. Attempt to run or build the project.
Current vs. Expected behavior

Current:

npm run build

> build
> next build

   ▲ Next.js 15.0.3-canary.6

   Creating an optimized production build ...
 ⨯ Next.js can't recognize the exported `config` field in route "/page":
Unsupported node type "BinaryExpression" at "revalidate".
Read More - https://nextjs.org/docs/messages/invalid-page-config
 ✓ Compiled successfully
 ✓ Linting and checking validity of types    
 ⨯ Invalid config value exports detected, these can cause unexpected behavior from the configs not being applied. Please fix them to continue

Expected: The mathematical expression to be evaluated

Provide environment information
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Fri Mar 29 23:14:13 UTC 2024
  Available memory (MB): 3921
  Available CPU cores: 4
Binaries:
  Node: 20.16.0
  npm: 10.8.1
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 15.0.3-canary.6 // Latest available version is detected (15.0.3-canary.6).
  eslint-config-next: N/A
  react: 19.0.0-rc-7c8e5e7a-20241101
  react-dom: 19.0.0-rc-7c8e5e7a-20241101
  typescript: 5.3.3
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

Not sure

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

next build (local)

Additional context

In Next.js 15, the revalidate field in route handlers does not support mathematical expressions (e.g. 60 * 5). This behavior was supported in Next.js 14, which accepted expressions that evaluated to integers.

Instead, Next.js 15 only supports direct integer values for revalidate.
eg.

export const revalidate = 300; // 60*5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction and the route handler that exports revalidate; run npm run build with Next.js 15 to reproduce the unsupported BinaryExpression error. Compare the behavior with Next.js 14, then verify that a mathematical expression such as 60 * 5 is accepted and the production build completes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js
Domain
build-system, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.