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

NaN marshaling issue in setup() method #2808

Open
olegbespalov opened this issue Dec 7, 2022 · 1 comment
Open

NaN marshaling issue in setup() method #2808

olegbespalov opened this issue Dec 7, 2022 · 1 comment
Labels
bug evaluation needed proposal needs to be validated or tested before fully implementing it in k6 lower prio

Comments

@olegbespalov
Copy link
Contributor

Brief summary

Currently, if data that is going to return from the setup method contains a NaN value, k6 will fail with the error:

ERRO[0000] error marshaling setup() data to JSON: json: unsupported value: NaN

But for instance, marshaling an object that contains NaN in other places doesn't cause such an error.

Also, since by default, we marshal NaN as null, it's hard to figure out which property causes the issue for users.

For example:

let data = {x: null, y: NaN}
console.log(data)

will output to logs as:

INFO[0000] {"x":null,"y":null}                           source=console

So ideally, we should either improve the error message or fix the current behavior (e.g. treat the NaN as null)

Initially raised in community forums.

k6 version

v0.41.0

OS

linux/amd64

Docker version and image (if applicable)

No response

Steps to reproduce the problem

Given a script.js

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

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

k6 run script.js

Expected behaviour

k6 runs as it should or explicitly say what's wrong.

Actual behaviour

ERRO[0000] error marshaling setup() data to JSON: json: unsupported value: NaN
@olegbespalov olegbespalov added bug lower prio evaluation needed proposal needs to be validated or tested before fully implementing it in k6 labels Dec 7, 2022
@na--
Copy link
Member

na-- commented Dec 7, 2022

Somewhat connected to #2579?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug evaluation needed proposal needs to be validated or tested before fully implementing it in k6 lower prio
Projects
None yet
Development

No branches or pull requests

2 participants