From ebcdf684312132ff8c9082e3d481b8fd185830be Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Thu, 10 Nov 2022 11:03:43 -0500 Subject: [PATCH] defend against infinite loop on broken babel config It's not legal to have an empty array as a plugin in a babel config -- that definitely makes babel blow up. But in that case, our serialization code runs first and can get trapped in an infinite loop on the bad plugin. This prevents the loop so you can get to the real babel crash instead. --- packages/core/src/portable-babel-config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/portable-babel-config.ts b/packages/core/src/portable-babel-config.ts index 80200c137..db87ea786 100644 --- a/packages/core/src/portable-babel-config.ts +++ b/packages/core/src/portable-babel-config.ts @@ -72,7 +72,7 @@ class PortableBabelConfig { // trim back down our array, because trailing undefined will get // converted into null via json.stringify, and babel will complain // about that. - while (dehydrated.value[dehydrated.value.length - 1] == null) { + while (dehydrated.value.length > 0 && dehydrated.value[dehydrated.value.length - 1] == null) { dehydrated.value.pop(); } if (dehydrated.value.length === 1) {