Regarding 2, the default errors thrown when calling abort() or timeout() have no shared prototype and have changed in various node releases. As such you cannot do an instanceof check with eg. Bounce.rethrow(err, AbortError). The most compatible way to detect this, is to simply check that the name property is AbortError. Given this, I have added shortcuts to do it safely.
Note that I have marked these as breaking, not because of the API changes, but solely because it requires more modern versions of node (v16.17+) then the current release.
This is done in 2 ways:
signal
option torethrow()
andignore()
.AbortSignal
derived aborts and timeouts.Regarding 1, this allows a
Bounce
user to simply hook asignal.rethrowIfAborted()
into the call. Eg.:Alternatively, you would need an extra
signal.rethrowIfAborted()
before the call to Bounce, which gets verbose:Regarding 2, the default errors thrown when calling
abort()
ortimeout()
have no shared prototype and have changed in various node releases. As such you cannot do aninstanceof
check with eg.Bounce.rethrow(err, AbortError)
. The most compatible way to detect this, is to simply check that thename
property isAbortError
. Given this, I have added shortcuts to do it safely.Note that I have marked these as breaking, not because of the API changes, but solely because it requires more modern versions of node (v16.17+) then the current release.