Trouble with .toLocaleString in latest version of Docker

Running n8n via [Docker] Version 0.212.0

Odd behaviour with .toLocaleString(‘en-US’)

This works
{{ $node[“HTTP Get Vatom Stats”].json[“data”][“payload”][“vee_amount”] }}

Output is
290364337.4799991

I want to convert that to String with commas, so I added .toLocaleString(‘en-US’)

{{ $node[“HTTP Get Vatom Stats”].json[“data”][“payload”][“vee_amount”].toLocaleString(‘en-US’) }}

But this has resulted in
[undefined]

Any clues, please

2 Likes

i had something similar

1 Like

Same here with n8n 0.212.1 and PostgreSQL in two separate containers in Docker 20.10.23

{{ $now.setLocale(‘en’).toLocaleString({weekday: ‘long’}) }}
→ Result: [undefined]

{{ $now.setLocale(‘en’).toLocaleString() }}
→ Result: 1/26/23, 4:00 PM

However, as I workaround I was able to use {{ $now.setLocale(‘en’).toFormat(‘EEEE’) }}

Clearly, a bug that was recently introduced. How do we get a response from the team please.

Perhaps they failed to include the .toFormat and .setLocale in the latest build ???

I think I’ve found an explanation for this issue:

At least in 0.212.1, .toLocaleString('en-US') works just fine.

What used to work and doesnt work anymore, is the mentioned format .toLocaleString({weekday: ‘long’}), or toLocaleString(DateTime.TIME_24_WITH_SECONDS). What I think happened, is that this previously valid syntax is not valid anymore, and now you have to pass the locale as the first parameter, even if it is empty.

So: .toLocaleString('en-US', {weekday: ‘long’}) and even .toLocaleString('', {weekday: ‘long’}) are both valid. For some reason, toLocaleString(DateTime.DATE), without the locale parameter also seem to be valid…

I do believe this is unintended or at least not well documented behavior, as it is a breaking change and the (now) invalid syntax is mentioned in documentation:

From the Luxon docs:

Defaults to the system’s locale if no locale has been specified

Hi

Sadly I have to report that your theory is not correct.

Please see the following with and without .toLocaleString(‘en-US’

{{
$node["HTTP Get Vatom Stats"].json["data"]["payload"]["vee_amount_24h"]
}}

Result: 121183.79000000002


{{
$node["HTTP Get Vatom Stats"].json["data"]["payload"]["vee_amount_24h"].toLocaleString('en-US')
}}

Result: [undefined]


It is not a syntax error. The result is [undefined]

Same problem here.

I have just taken a quick look and using {{ $now.toLocaleString('en-US') }} is working so it looks like the option does still work.

@anderfesouza can you share the date you are trying to format?

I think you may be addressing a different problem than was originally posted

I was applying .toLocaleString(‘en-US’) to a number

This fails with a Result: [undefined]

I was just ruling out a general failing, I did see your number and hit the same issue but I also can’t work out what format that number is which would be a big help in working out where it is going wrong.

i pull the number from an http service .
Is there a command I can use to inspect the number and get you the info you need?

The number is here 290364337.4799991 from the original post but what is that date meant to be?

The number we have is not a date.

I wanted to convert it to a number with commas.

I had originally used .toLocaleString(‘en-US’, {maximumFractionDigits:0})

which worked prior to the upgrade

this now fails so I tried the simpler .toLocaleString(‘en-US’)

Which also now fails

Ah ok, That explains it. I have only ever seen .toLocaleString used with dates not numbers. I have just given that a test and it appears to work as well.

My test workflow is below.

I upgraded the Docker version to 0.214.0

This now works.

It absolutely failed on version 0.212.0

Thanks for the help

I wonder if there was something changed in the docker builds between those 2 versions

Anyway. Case closed, and thanks again @Jon

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.