I am investigating a bug where the lcovonly reporter sometimes crashes. I cannot reproduce it reliably, but it happens about 60% of the time.
I was able to find part of the cause why it happens, but I need help to find the root cause and solve it.
The lcovonly report failed at this line because the branchMap and b properties of the file coverage had different keys. It is a broken invariant, meaning that the coverage map was malformed.
The bad file coverage object was for a file called test.esm.js. When looking into c8's tmp directory (coverage/tmp), I found two coverage file for test.esm.js: gist.
If you look at them, you see that they have different branchMap values. The first one has 2 properties, the second one has 4 properties.
When c8 builds its coverage map, it merges all the files in its temporary directory. One of the preconditions of the merge function is that if there are two reports for the same file, the file needs to have the same structure (ex. branchMap). https://github.com/istanbuljs/istanbuljs/blob/829e658dfa91e3a9533842be9ce940dbe7785c09/packages/istanbul-lib-coverage/lib/file.js#L246.
So here is the current state of my investigation: lcovonly breaks because it gets an invalid file coverage because multiple reports for the same file but with different structures are merged, thus breaking one of the preconditions of the merge function.
To solve this, c8 should ensure that the reports are unique for each file URL, and that they have the same structure.
I am investigating a bug where the
lcovonlyreporter sometimes crashes. I cannot reproduce it reliably, but it happens about 60% of the time.I was able to find part of the cause why it happens, but I need help to find the root cause and solve it.
The
lcovonlyreport failed at this line because thebranchMapandbproperties of the file coverage had different keys. It is a broken invariant, meaning that the coverage map was malformed.The bad file coverage object was for a file called
test.esm.js. When looking into c8's tmp directory (coverage/tmp), I found two coverage file fortest.esm.js: gist.If you look at them, you see that they have different
branchMapvalues. The first one has 2 properties, the second one has 4 properties.When
c8builds its coverage map, it merges all the files in its temporary directory. One of the preconditions of the merge function is that if there are two reports for the same file, the file needs to have the same structure (ex.branchMap). https://github.com/istanbuljs/istanbuljs/blob/829e658dfa91e3a9533842be9ce940dbe7785c09/packages/istanbul-lib-coverage/lib/file.js#L246.So here is the current state of my investigation:
lcovonlybreaks because it gets an invalid file coverage because multiple reports for the same file but with different structures are merged, thus breaking one of the preconditions of the merge function.To solve this, c8 should ensure that the reports are unique for each file URL, and that they have the same structure.