One misplaced beforeEach hook caused 36 hours of CI timeouts in PostgreSQL test suite
A software team's CI pipeline repeatedly timed out over 36 hours across six failed GitHub Actions runs, all traced to a single line in their test setup file. A beforeEach hook was executing a TRUNCATE TABLE CASCADE command across 76 database tables before every one of 1,140 tests, generating over 86,000 expensive PostgreSQL operations. The pattern had worked earlier when the suite was smaller, but silently crossed a performance threshold as the codebase grew, and the problem went unnoticed because developers ran only partial test suites locally. The fix involved switching from beforeEach to beforeAll to truncate tables just once per suite, using unique randomised test data to avoid cross-test collisions, and adding a 15-minute explicit timeout to CI steps for faster failure detection. After the changes, the test suite runtime dropped from over six hours to approximately three minutes.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in