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

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

Open
GitDevla opened this issue Nov 5, 2024 · 1 comment
Labels
bug Issue was opened via the bug report template.

Comments

@GitDevla
Copy link

GitDevla commented Nov 5, 2024

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
@GitDevla GitDevla added the bug Issue was opened via the bug report template. label Nov 5, 2024
@james-han
Copy link

I encountered this issue as well. Currently, the only workaround I found is to change const to let, which temporarily resolves the build issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants