ava: `after.always` doesn't run if there are uncaught exceptions

Hi! This is the second time I read the documentation at README.md and find that the feature I’m using is not yet released (after some debugging). I’m not sure what it was last time, but this time it is after.always found in commits since release.

Any thoughts about stabilizing/syncing the docs with the release cycle?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (14 by maintainers)

Commits related to this issue

Most upvoted comments

@fcastilloec you could use t.try() (though I don’t recall if that’s available in hooks). It lets you observe the outcome and should let you set a separate timeout. That way if there’s an error or a timeout you can then run some other code before proceeding with the failure.

Does anybody know of a workaround for this? In my case, a process in the before hook might not load and hence timeout. This program only outputs errors and messages to a file (there’s no console whatsoever). I was counting on using the after.always hook to read the error file and print it on the terminal even if my before hook timeouts or errors. I could run a program doing this if ava fails but I really would like to have it integrated as part of my test. Any way to force ava to run something at the end, no matter what?

Hey @Githubber2021, I think this comment still stands:

Uncaught exceptions crash the worker process. We can’t really make any guarantees about whether after hooks are run.