next.js
a341ef9e - Fix varyParams tracking for optional catch-all params with no value (#90496)

Commit
22 hours ago
Fix varyParams tracking for optional catch-all params with no value (#90496) When an optional catch-all param like `[[...slug]]` has no value (e.g., visiting `/docs` instead of `/docs/foo`), the param doesn't exist as a property on the params object. The existing varyParams tracking uses `defineProperty` getters, which only work for properties that exist. This meant the segment cache couldn't tell that the page depended on the missing param, causing it to incorrectly reuse cached content across different param values. Fix this by using a Proxy when an optional catch-all param has no value. The Proxy intercepts property access, the `in` operator, and object enumeration to track whether the page's rendering depends on the param, even though it's absent from the object. The optional catch-all param name is propagated from the catch-all's layout segment to its child page segment during tree traversal, so the page's params object knows to use Proxy-based tracking.
Author
Parents
Loading