You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: finally block in async function indicates incorrect missing block coverage #229
I'm not sure if it's related, but I think I hit this? I happened to be on c8 v7.4.0 when I encountered the failure in CI, but it reproduces in v7.5.0 when run on node v12.20.1.
The tests pass, it's just the mysterious coverage gap on an async function that fails in node v12. v14 is fine.
To be clear, the node v14 I was passing with is v14.15.4. Which tracks, given the release of the linked back-porting. I have literally no idea if it could (or should?) be back-ported to v12, though it seems like a good candidate if someone has bandwidth?
@evocateur there are some v8 bug fixes that have landed in v14/v15, that I don't think got backported to v12 unfortunately -- I'm pretty sure that v12 might be closed to extension at this point unfortunately.
@bcoe Perfectly fair! Especially considering it's going into maintenance mode in like, 2 months? So I'll probably drop v12 before I even finish this wee babby of a tool, lol.
I'm encountering something similar. My finally block has a coverage of 26, while the keyword finally has no coverage.
I'm using 5 finally statements in the entire solution, 4 of them are working as expected, only this one has no coverage. I have no idea how this is possible.
I can send you a link to the code so you can see the problem yourself.
Update
Noticed that if you remove the throw statement in the catch block, that the finally is hit. However the amount of hits seems wrong.
@bcoe I have run into a similar issue as reported by @xolott, where the generated output is showing the finally block as uncovered. If you are still interested in troubleshooting, here is a minimum example repro
EDIT: Just noticed that if you change the handler to finish without returning then the finally block is marked as covered: await orchestrator.activate()
Activity
bcoe commentedon Jun 19, 2020
I have created a tracking issue on v8 here:
https://bugs.chromium.org/p/v8/issues/detail?id=10628
deps: V8: backport 2d5017a0fc02
deps: V8: backport 2d5017a0fc02
deps: V8: backport 2d5017a0fc02
test: Inexplicably fix coverage in node v12
evocateur commentedon Feb 3, 2021
I'm not sure if it's related, but I think I hit this? I happened to be on c8 v7.4.0 when I encountered the failure in CI, but it reproduces in v7.5.0 when run on node v12.20.1.
The tests pass, it's just the mysterious coverage gap on an async function that fails in node v12. v14 is fine.
dendrochronologist/cli@edd0aaf "fixes" it by ignoring the missed line. Not ideal, long-term.
However, if I avoid using the
asynckeyword, it passes again:I validated this locally with
evocateur commentedon Feb 3, 2021
To be clear, the node v14 I was passing with is v14.15.4. Which tracks, given the release of the linked back-porting. I have literally no idea if it could (or should?) be back-ported to v12, though it seems like a good candidate if someone has bandwidth?
bcoe commentedon Feb 5, 2021
@evocateur there are some v8 bug fixes that have landed in v14/v15, that I don't think got backported to v12 unfortunately -- I'm pretty sure that v12 might be closed to extension at this point unfortunately.
evocateur commentedon Feb 6, 2021
@bcoe Perfectly fair! Especially considering it's going into maintenance mode in like, 2 months? So I'll probably drop v12 before I even finish this wee babby of a tool, lol.
simlu commentedon Mar 31, 2022
Just ran into this one as well. Rough one to debug. Any update regarding a fix?
milanholemans commentedon Sep 15, 2022
I'm encountering something similar. My
finallyblock has a coverage of 26, while the keywordfinallyhas no coverage.I'm using 5
finallystatements in the entire solution, 4 of them are working as expected, only this one has no coverage. I have no idea how this is possible.I can send you a link to the code so you can see the problem yourself.
Update
Noticed that if you remove the
throwstatement in thecatchblock, that thefinallyis hit. However the amount of hits seems wrong.xolott commentedon Oct 13, 2022
I'm also getting the same issue with a
finallyblock. But this is not an async function.Everything is 100% covered but the branch reports a 96.15% coverage
I just added an ignore comment for now

bcoe commentedon Nov 3, 2022
@xolott would you be able to provide a minimal breaking example, this would help in investigating the underlying cause.
archiehharris commentedon Jun 14, 2024
@bcoe I have run into a similar issue as reported by @xolott, where the generated output is showing the finally block as uncovered. If you are still interested in troubleshooting, here is a minimum example repro
EDIT: Just noticed that if you change the handler to finish without returning then the finally block is marked as covered:
await orchestrator.activate()