toLocaleString() inconsistent behavior is causing error #418 - hydration mismatch #79397
-
On the company website I’m working on, we format product prices using |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I've experienced this with South African currency, nodejs/node#48120 Could this indicate that the environment running your revalidation, has a runtime with an issue, or not updated version? Like, locally, I run Welcome to Node.js v22.14.0.
Type ".help" for more information.
> const number = 1000
undefined
>
> // request a currency format
undefined
> console.log(
... number.toLocaleString("it-IT", { style: "currency", currency: "EUR" }),
... );
1000,00 € However, Node 20.11.1: Welcome to Node.js v20.11.1.
Type ".help" for more information.
> const number = 1000
undefined
>
> // request a currency format
undefined
> console.log(
... number.toLocaleString("it-IT", { style: "currency", currency: "EUR" }),
... );
1.000,00 €
undefined
> Which is somewhat what you describe. I wonder if the revalidate environment is not running the proper Node.js version somehow. Also Chrome does: const number = 1000
// request a currency format
console.log(
number.toLocaleString("it-IT", { style: "currency", currency: "EUR" }),
);
1.000,00 € So is Node 22.14.x, somehow doing it wrong? 🤔 I'd say, check in other browsers and runtimes. Firefox, Safari and Bun gives me: |
Beta Was this translation helpful? Give feedback.
-
You definitely got it right! I'm using I'm getting the numbers correctly displayed on both Chrome and Safari (17.3) where V8 and Nitro should take over, at least for client components. |
Beta Was this translation helpful? Give feedback.
I've experienced this with South African currency, nodejs/node#48120
Could this indicate that the environment running your revalidation, has a runtime with an issue, or not updated version?
Like, locally, I run
node 22
with this:However, Node 20.11.1: