diff --git a/CHANGELOG.md b/CHANGELOG.md index aae2453..7f133ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/lib/init.lua b/lib/init.lua index 091cf11..56a9f42 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -1616,9 +1616,15 @@ function Promise.prototype:awaitStatus() if self._status == Promise.Status.Started then local thread = coroutine.running() - self:finally(function() - task.spawn(thread) - end) + 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