Skip to content

Truly independent web browser

Tests/LibJS: Test async-from-sync iterators at the stack size limit

sideshowbarker04c2a072e1de
diff --git a/Tests/LibJS/Runtime/runtime-error-call-stack-size.js b/Tests/LibJS/Runtime/runtime-error-call-stack-size.js
index 74e05887508..de147cc9db9 100644
--- a/Tests/LibJS/Runtime/runtime-error-call-stack-size.js
+++ b/Tests/LibJS/Runtime/runtime-error-call-stack-size.js
@@ -31,3 +31,18 @@ test("infinite recursion", () => {
outer();
}).toThrowWithMessage(InternalError, "Call stack size limit exceeded");
});
+
+test("async-from-sync iterators created at the call stack size limit", () => {
+ // Every frame of the recursion starts a for-await loop over an array, the deepest ones with almost no stack left,
+ // and its async function catches the overflow in its rejected promise. See #12217.
+ const recurse = async () => {
+ try {
+ recurse();
+ } catch {}
+ for await (const _ of [0]);
+ };
+ expect(() => {
+ recurse();
+ gc();
+ }).not.toThrow();
+});