How to access environment/execution context variable when running with `--compatibility-mode=base`?

To see if I can reduce the memory footprint of a load test writting in k6 I am trying to convert it so it can be run in --compatibility-mode=base

I can’t seem to figure out how to access the ${__VU} variable when running in this mode.

I get this error:

Line 33:12 Unexpected token ILLEGAL (and 21 more errors)

Like 33 looks like this:

var vu = `${__VU}`;

Notice the tick marks surrounding the env var, which I don’t think it likes. How else can we access the __VU var in base compatibility mode?

Hello,

You should just be able to use var vu = __VU; (__VU is just an integer after all).

1 Like

As I’ve noted in Using compatibility-mode base - #3 by mstoykov there is now very little --compatibilty-mode=base may do for your memory usage(if anything at all), so you are better off following some of my other suggestions in that thread and if you still have problems to make a separate topic asking for help, obviously with more information :wink:

1 Like