From 4586cc5a90d5752b0fbe6e5221463ed6ec56858d Mon Sep 17 00:00:00 2001 From: David Duque Date: Sat, 2 May 2020 19:24:05 +0100 Subject: [PATCH] Use pcall() on Promise.is when looking for the .andThen function Some tables might have strict metatables that error if a non-existant member is indexed, causing the chain to fail. --- lib/init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/init.lua b/lib/init.lua index 1ab7e14..6687e66 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -471,7 +471,11 @@ function Promise.is(object) return false end - return type(object.andThen) == "function" + local ok, isPromise = pcall(function() + return type(object.andThen) == "function" + end) + + return ok and isPromise end --[[