From 14587cd4919c32adab357d8fb87dfdb46f57531f Mon Sep 17 00:00:00 2001 From: Eryn Lynn Date: Wed, 18 Sep 2019 17:58:07 -0400 Subject: [PATCH] Move unhandled rejection warning to hb --- CHANGELOG.md | 4 ++++ lib/init.lua | 21 ++++----------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abea1df..af967f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.3.1 + +- Make unhandled rejection warning trigger on next Heartbeat + # 2.3.0 - Remove `Promise.spawn` from the public API. diff --git a/lib/init.lua b/lib/init.lua index 3fa71d4..492d625 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -89,21 +89,6 @@ Promise.Status = { The callback will receive 'resolve' and 'reject' methods, used to start 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 promise chain. External code shouldn't need to worry about this. ]] @@ -615,7 +600,9 @@ function Promise.prototype:_reject(...) local err = tostring((...)) - spawn(function() + coroutine.wrap(function() + RunService.Heartbeat:Wait() + -- Someone observed the error, hooray! if not self._unhandledRejection then return @@ -627,7 +614,7 @@ function Promise.prototype:_reject(...) self._source ) warn(message) - end) + end)() end self:_finalize()