diff --git a/src/lune/scheduler/impl_async.rs b/src/lune/scheduler/impl_async.rs index 6f9a83e..fb3d0a8 100644 --- a/src/lune/scheduler/impl_async.rs +++ b/src/lune/scheduler/impl_async.rs @@ -14,10 +14,10 @@ where where F: Future + 'fut, { - let futs = self - .futures - .try_lock() - .expect("Failed to lock futures queue"); + let futs = self.futures.try_lock().expect( + "Failed to lock futures queue - \ + make sure not to schedule futures during futures resumption", + ); futs.push(Box::pin(fut)) } diff --git a/tests/globals/pcall.luau b/tests/globals/pcall.luau index 7293879..fa983cb 100644 --- a/tests/globals/pcall.luau +++ b/tests/globals/pcall.luau @@ -7,7 +7,10 @@ local PORT = 9090 -- NOTE: This must be different from local function test(f, ...) local success, message = pcall(f, ...) assert(not success, "Function did not throw an error") - assert(type(message) == "userdata", "Pcall did not return a proper error") + assert( + type(message) == "string" or type(message) == "userdata", + "Pcall did not return a proper error" + ) end -- These are not async but should be pcallable @@ -24,7 +27,7 @@ local handle = net.serve(PORT, function() return "" end) -task.delay(0, function() +task.delay(0.25, function() handle.stop() end)