Error running test as an Archive? (Expected \";\" but found \"\\x00\"")

Hello, I am trying to run a test as an archive.

My use-case is pretty niche but I want to run the archive command, untar that archive, make some changes to the files that are archived, and then re-archive it and run that re-archive.

Everything seems to be working fine until I try to run the re-archived test, I get an incredibly vague error:

FATA[0000]                                               error="k6-test-api--local-imports-archive.tar:1:13 Expected \";\" but found \"\\x00\""

It seems like it’s interpreting the tar archive as an actual script file instead of an archive. I’m not totally sure as this is the only output I get, even with the verbose flag.

This was the command that generates that error:

k6 run --no-usage-report --summary-export output/k6/summary.json --out csv=output/k6/metrics.csv -v k6-test-api--local-imports-archive.tar

EDIT: This appears to be an issue with the archive? I generated a new k6 script.js and immediately archived it, and even that archive cannot run, with the same error.

Okay, I am not sure why but this error was caused by using a binary that included the extension to allow typescript files to be used with k6.

I removed that extension and archives work again.

Hi @dmckernan,

Thanks for starting this thread. It sounds like a potential bug in the typescript extension. I’d like to try and replicate the issue on my side so that I can create a bug report if that is needed.

Could you please list all the commands you ran for the simple case where you generated a new k6 script.js, immediately archived it, and then the archive didn’t work with the error you mentioned in your first post?

These are the steps I tried with the latest v1.0.0 version of k6:

  1. Created a new test:
    import http from 'k6/http';
    
    export default function() {
        http.get('https://test.k6.io');
    }
    
  2. Ran k6 archive test.js, which created archive.tar.
  3. Ran k6 run archive.tar which was successful in running the test.

Best,
Ankur

Hi Ankur, here is the output of k6 --version from the binary used that presented the issue:

k6 v0.56.0 (go1.23.6, darwin/arm64)
Extensions:
  github.com/LeonAdato/xk6-output-statsd v0.2.1, output-statsd [output]
  github.com/avitalique/xk6-file v1.4.2, k6/x/file [js]
  github.com/grafana/xk6-ts v0.2.6, k6/x/fake-ts-module-just-for-k6-version-command [js]

As previously stated, yeah, that ts plugin seemed to be the culprit. After upgrading to 1.0.0 (and removing the plugin, since 1.0.0 now supports ts natively) running archives started to work again.

It’s important to note that the archive does create successfully, however, it just couldn’t run them.

The steps used were as follows (in any directory):

  1. k6 new
  2. k6 archive script.js
  3. k6 run archive.tar

If I had to guess, the typescript extension maybe thought the tar file was a ts file, since they both start with t, causing it to try to interpret the archive as typescript? (That’s what the error seemed like anyway)