Skip to content

Commit

Permalink
defend against infinite loop on broken babel config
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ef4 committed Nov 10, 2022
1 parent 3b0dd91 commit ebcdf68
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core/src/portable-babel-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ebcdf68

Please sign in to comment.