Data output from setup: ERRO[0132] error marshaling setup() data to JSON: json: unsupported value: NaN

I get this error when I try to preprocess my data from the setup function in a k6 test:
ERRO[0132] error marshaling setup() data to JSON: json: unsupported value: NaN

I do not know what this means, or where to find documentation about this.
If I print out the data, it looks like proper JSON and it contains zero NaN values.

How do I debug this?
Many thanks!

Hi @xor!

Welcome to the community forums! :wave:

It seems like at some point, your setup data got a NaN value which is not supported as the value there.

export function setup() {
   return {y: NaN}
}

export default (data) => {
   console.log(data)
}

I have to double-check and probably open an issue in our GitHub. However, some workaround is possible, like defaulting to any other value (including null):

export function setup() {
   return {y: NaN || 0}
}

export default (data) => {
   console.log(data)
}

Let me know if that answers,
Cheers!

Further investigations and discussions in GitHub issue `NaN` marshaling issue in `setup()` method · Issue #2808 · grafana/k6 · GitHub

1 Like