Move unhandled rejection warning to hb

This commit is contained in:
Eryn Lynn 2019-09-18 17:58:07 -04:00
parent ffaff8a4b1
commit 14587cd491
2 changed files with 8 additions and 17 deletions

View file

@ -1,3 +1,7 @@
# 2.3.1
- Make unhandled rejection warning trigger on next Heartbeat
# 2.3.0 # 2.3.0
- Remove `Promise.spawn` from the public API. - Remove `Promise.spawn` from the public API.

View file

@ -89,21 +89,6 @@ Promise.Status = {
The callback will receive 'resolve' and 'reject' methods, used to start The callback will receive 'resolve' and 'reject' methods, used to start
invoking the promise chain. invoking the promise chain.
For example:
local function get(url)
return Promise.new(function(resolve, reject)
spawn(function()
resolve(HttpService:GetAsync(url))
end)
end)
end
get("https://google.com")
:andThen(function(stuff)
print("Got some stuff!", stuff)
end)
Second parameter, parent, is used internally for tracking the "parent" in a Second parameter, parent, is used internally for tracking the "parent" in a
promise chain. External code shouldn't need to worry about this. promise chain. External code shouldn't need to worry about this.
]] ]]
@ -615,7 +600,9 @@ function Promise.prototype:_reject(...)
local err = tostring((...)) local err = tostring((...))
spawn(function() coroutine.wrap(function()
RunService.Heartbeat:Wait()
-- Someone observed the error, hooray! -- Someone observed the error, hooray!
if not self._unhandledRejection then if not self._unhandledRejection then
return return
@ -627,7 +614,7 @@ function Promise.prototype:_reject(...)
self._source self._source
) )
warn(message) warn(message)
end) end)()
end end
self:_finalize() self:_finalize()