Difference on k6 vs k6.exe?

Hi there, I have simple k6 script that does a POST request using FormData polyfill.

*My project is running .NET Core.

I have a Windows machine, having installed k6 through the official Windows installation guide. My script runs smoothly against my localhost site if I do:

  • k6 run .\ProjectFolder\Load\MyTestScript.js

Then I started to work on GitHub Actions to test my solution on PRs automatically. And since my Cloud environment is also a Windows environment without choco or winget, I had to manually extract & download the binaries on my -yml script, following this official guide.

Then, I started to see some issues and tried to replicated on my machine. If I use k6.exe on Windows PowerShell, I get the following error running the same script as:

  • k6.exe run ProjectFolder\Load\MyTestScript.js:

{"errors":{"":["Failed to read the request form. Unexpected end of Stream, the content may have already been read by another component. "]},"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"00-84ffc94dd07da8080c5a1386c3ecb65b-27be1c8b94871d44-00"}

Does anyone seen any differences running k6 vs k6.exe? It’s awkward to think the bug is on the site since it runs without issues on the first option.

An example what the script might look like:

import http from "k6/http";
import { check, sleep } from "k6";
//k6 does not support standard FormData js library
import { FormData } from "https://jslib.k6.io/formdata/0.0.2/index.js";

export default function () {
    const url = "http://localhost:9005/api/";
    console.log("building form..");
    const fd = new FormData();
    fd.append("Field1", `StringGoesHere`);
    fd.append("Field2", ``);
    fd.append("Field3", `1.0.0`);
    fd.append("Field4", `Dummy`);
    fd.append("Field5", `1.0.0`);

    const headers = {
        'Content-Type': `multipart/form-data; boundary=${fd.boundary}`,
        'Authorization': "Bearer XYZ=="
    };

    const response = http.post(url + "apiMethod", fd.body(), { headers });

    check(response, {
        'POST is status 200': (x) => x.status === 200
    });

    sleep(1);
}

TLDR: I get an error if I run a k6 script using k6.exe executable whereas if I use k6, I don’t.

Thanks in advance.

Hi @daniellourencorj

Welcome to the community forums! :wave:

It seems weird :thinking: But we probably need more details since the quick run of the test similar script (it’s just pointing to the k6’s test endpoints) shows nothing suspicious.

import http from "k6/http";
import { check, sleep } from "k6";
//k6 does not support standard FormData js library
import { FormData } from "https://jslib.k6.io/formdata/0.0.2/index.js";

export default function () {
    const url = "https://httpbin.test.k6.io/post";
    console.log("building form..");
    const fd = new FormData();
    fd.append("Field1", `StringGoesHere`);
    fd.append("Field2", ``);
    fd.append("Field3", `1.0.0`);
    fd.append("Field4", `Dummy`);
    fd.append("Field5", `1.0.0`);

    const headers = {
        'Content-Type': `multipart/form-data; boundary=${fd.boundary}`,
        'Authorization': "Bearer XYZ=="
    };

    const response = http.post(url, fd.body(), { headers });

    check(response, {
        'POST is status 200': (x) => x.status === 200
    });

    sleep(1);
}

Does the issue remain across every run? What version of the k6 are you using (k6 version and, just in case k6.exe version)?

Cheers!