Error appears only from time to time "failed to create a new parser" when using open and csv from k6 experimental library

I changed the way i am reading and parsing csv files into my js scripts. Previously I was using papaparse.js and now I am using open and csv structures from ‘k6/experimental/fs’ and csv from ‘k6/experimental/csv’.

I have multiple javascript files where I am having this structure declared before declaring the main function:

ScriptA

const file1 = await open(`../LT_data/${beneAccEnv}.csv`);
export const csvBeneAcc = await csv.parse(file1, {asObjects:true});

Script B

const file2 = await open(`../LT_data/${beneAccEnv}.csv`);
export const csvBeneAcc = await csv.parse(file2, {asObjects:true});

So, multiple scripts are taking data from this csv file. Then I created a scenario which is starting paralel threads with these scripts.

Sometimes when running the scenario i have this error:

level=error msg=“failed to create a new parser; reason: failed to read the first line; reason: EOF\n” hint=“script exception”.

Appears randomly (when running locally or using k6 agents).

This did not happened previously when using papaparse.js. It only happens now from time to time when using the experimental library. We do not have a pattern for this issue.

Hi @larisaadriana85,

First of all, sorry for the big delay on the response, I lost track of this and never came back… until now!!

Have you tried with the most recent release? For instance, in v1.6.0 and v1.6.1 we shipped this and this, which are a couple of fixes and improvements for the `k6/experimental/csv` module. Especially, the first one might help with those cases where you read the same file in multiple places.

Please, let me know if it keeps failing for you and I’ll take a look.

Thanks! :person_bowing: