Harness/Docker/k6 error: function 'default' not found in exports

I’ve been running this test script locally without issue, but when I try to run it in the grafana/k6 container it fails with exit code 104 and this message:

time=“2022-10-21T20:02:07Z” level=error msg=“There were problems with the specified script configuration:\n\t- executor default: function ‘default’ not found in exports”

My script does not have a default function but it runs fine locally on my macbook pro. Here’s the main script:

import http from 'k6/http';
import { check, group } from 'k6';
import { SharedArray } from 'k6/data';
import * as query from './queryLib.js';

let orgName = 'prerelease-performance-2';//`${__ENV.orgName}`
const BASE_URL = 'https://' + orgName + '.greenlight.guru'
const userData = new SharedArray('userData', function () {
    return JSON.parse(open('./userData.json')).users;

let metrics = [];

export function setup(){
    let userObject = {"users": [], "org": orgName};
        let theUser = {};
        theUser['email'] = v.email;
        theUser['pword'] = v.pword;
        theUser['userName'] = v.user;
    return userObject;

export const options = {
    scenarios: {
        groupOne: {
            executor: 'constant-arrival-rate',
            exec: 'groupOne',
            rate: 1,//5,
            timeUnit: '1s',
            duration: '120s',
            preAllocatedVUs: 10
        groupTwo: {
            executor: 'constant-arrival-rate',
            exec: 'groupTwo',
            rate: 1,
            duration: '120s',
            preAllocatedVUs: 10

export function groupOne(data) {

export function groupTwo(data) {

So I have 2 questions. Why doesn’t this run in the docker container and is there a work around?


Hi @mellema,

Can you please tell me if you provided any cli arguments when calling it within docker, and if yes, which ones.

I would expect that you have likely provided --duration 10m or something similar in which case the whole scenarios gets reevaluated and replaced with a much simpler one that will execute the default function.

There is an open issue to make this more … explicit as in to tell users that this has happened, but unfortunately nobody has picked it up :frowning:

As a workaround I would recommend not directly using those but instead defining your own --env some_duration=10s and then using it as __ENV.some_duration within your script.

This is the same for --iterations, --vus and --stages

Hope this helps you!

1 Like

Thanks @mstoykov ! That fixed the issue