From ca754a1f86b60c460725f3d196e51f009e83c24d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Hamburger=20Gr=C3=B8ngaard?= Date: Wed, 4 Nov 2026 14:55:46 +0000 Subject: [PATCH] test: rethrow stack overflows in the sanity-bridge oracle reference The reference conversion's `safeGetOf` swallowed every error thrown by a schema getter, including a `RangeError` when the call stack ran out inside one. The recursion then returned early instead of overflowing, so the cycle scenario's `toThrow(RangeError)` failed on some runs. The fuzz rounds had the same hole: a swallowed overflow gave a truncated reference result to compare against. --- .../sanity-schema-to-portable-text-schema.oracle.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/sanity-bridge/src/sanity-schema-to-portable-text-schema.oracle.test.ts b/packages/sanity-bridge/src/sanity-schema-to-portable-text-schema.oracle.test.ts index bdf0586eed..2773bf05fe 100644 --- a/packages/sanity-bridge/src/sanity-schema-to-portable-text-schema.oracle.test.ts +++ b/packages/sanity-bridge/src/sanity-schema-to-portable-text-schema.oracle.test.ts @@ -532,8 +532,13 @@ function safeGetOf(schemaType: SchemaType): readonly SchemaType[] | undefined { const arrayOf = (schemaType as ArraySchemaType).of return Array.isArray(arrayOf) ? arrayOf : undefined } - } catch { - // Sanity schema getters can throw -- ignore + } catch (error) { + // Sanity schema getters can throw, which is ignored. A stack overflow + // is rethrown: swallowing it lets the recursion return early and hides + // the overflow the cycle scenario expects. + if (error instanceof RangeError) { + throw error + } } return undefined }