Fix unhandled rejection warning with await

Closes #80
This commit is contained in:
eryn L. K 2022-03-02 19:02:21 -05:00
parent e23601b924
commit cab1c5ec8b
2 changed files with 13 additions and 3 deletions

View file

@ -1,5 +1,9 @@
# Changelog
## Unreleased
### Fixed
- Fix unhandled rejection warning appearing when using :awaitStatus
## [4.0.0-rc.2] - 2022-01-02
### Fixed
- Fix bug where Promise.fold does not return correct value if there is an unresolved Promise in the passed list (#77)

View file

@ -1616,9 +1616,15 @@ function Promise.prototype:awaitStatus()
if self._status == Promise.Status.Started then
local thread = coroutine.running()
self:finally(function()
self
:finally(function()
task.spawn(thread)
end)
-- The finally promise can propagate rejections, so we attach a catch handler to prevent the unhandled
-- rejection warning from appearing
:catch(
function() end
)
coroutine.yield()
end