Each VUs to receive returned values from another export function independently and not shared

This post was flagged by the community and is temporarily hidden.

What you are describing is not possible as k6 VUs are completely separate and currently there is no way for you to share state.

I did run the following code:

dataMonthDay.js:

var num = 0
export const incrementDay = () => {
        num++;
        return num;
};

main.js

import * as dateVal from './dateMonthDay.js';

export default function() {
        const num = dateVal.incrementDay();
        console.log(`VU: ${__VU}  -  ITER: ${__ITER}`, `Returned number is: ${num}`);
}

And got exactly what you want … separate return values for each VU.

As I’ve asked you in the stackoverflow question you asked, please provide the implementation of the function you think works in this sharing way. Also a version of k6 might be useful :thinking:

Irregardless this should not be possible and I would expect that it isn’t possible given how it behaves for me :wink:

Hi @mstoykov, you were right. I think I missed a line or mislook the results earlier when I was spending time scripting this part. Lesson learned for me. Double check the script or results before asking for help. Sorry for the confusion and the time spent dealing with my concern.

But still, I was able to gain some information or facts from you regarding how this concept work. Thanks for the explanation! Will delete this post in a while. :relaxed:

1 Like