Just start over

Just start over
Photo by Kier... in Sight / Unsplash

I was on the cusp of finishing a complex component. The changes looked good locally so I pushed to CI, waiting for the green check mark and the immediate dopamine kick.

Bang, a red cross. What the #!^^?

Uncaught RangeError: Maximum call stack size exceeded the log read when running the tests. Since the log didn't tell me which test caused the infinite loop, I started with the ones related to the component. They all passed on my machine.

I then went on to running the biggest chunk of tests that had some traces in the log might have run last before the error. Nothing, they were all green when running them locally.

I then stripped out lines of code which I thought wouldn't affect the tests otherwise (the component was not yet used in acceptance tests), sort of like git bisect but without having separate commits for each. The same infinite loop error, no matter how many lines I removed.

When I reverted all the changes on the branch and it still triggered the same error, the possible solution came to me like an angel with wings: just start a new branch, add the same commits and see if there's luck.

And there it was: a beautiful green check mark and a mergable PR, the sight of which we all crave every day.

They say programming and running code on computers is like science: everything has an explanation and the same input usually produces the same output. It's engineering after all.

Maybe that's true most of the time but on the days it's not, just start from scratch and see if you get lucky.