mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibJS: Handle call stack limit exceptions in NewPromiseReactionJob
The promise job's fulfillment / rejection handlers may push an execution context onto the VM, which will throw an internal error if our ad-hoc call stack size limit has been reached. Thus, we cannot blindly VERIFY that the result of invoking these handlers is non-abrupt. This patch will propagate any internal error forward, and retains the condition that any other error type is not thrown.
This commit is contained in:
@@ -58,7 +58,7 @@ static ThrowCompletionOr<Value> run_reaction_job(VM& vm, PromiseReaction& reacti
|
||||
// f. If promiseCapability is undefined, then
|
||||
if (promise_capability == nullptr) {
|
||||
// i. Assert: handlerResult is not an abrupt completion.
|
||||
VERIFY(!handler_result.is_abrupt());
|
||||
MUST_OR_THROW_INTERNAL_ERROR(handler_result);
|
||||
|
||||
// ii. Return empty.
|
||||
dbgln_if(PROMISE_DEBUG, "run_reaction_job: Reaction has no PromiseCapability, returning empty value");
|
||||
|
||||
@@ -18,4 +18,16 @@ test("infinite recursion", () => {
|
||||
expect(() => {
|
||||
new Proxy({}, { get: (_, __, p) => p.foo }).foo;
|
||||
}).toThrowWithMessage(InternalError, "Call stack size limit exceeded");
|
||||
|
||||
expect(() => {
|
||||
function outer() {
|
||||
async function inner() {
|
||||
await outer;
|
||||
}
|
||||
inner();
|
||||
outer();
|
||||
}
|
||||
|
||||
outer();
|
||||
}).toThrowWithMessage(InternalError, "Call stack size limit exceeded");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user