Skip to content

fix: serialize prettier formatting to prevent flaky tests#106

Open
veksen wants to merge 2 commits intomainfrom
veksen/fix-flaky-case-test
Open

fix: serialize prettier formatting to prevent flaky tests#106
veksen wants to merge 2 commits intomainfrom
veksen/fix-flaky-case-test

Conversation

@veksen
Copy link
Copy Markdown
Member

@veksen veksen commented Apr 2, 2026

Summary

  • prettier-plugin-sql is not safe to call concurrently. QueryCache.sync() runs up to 10 RecentQuery.analyze() calls in parallel, each calling prettier.format(). Under CI load, some calls throw silently (caught by the existing try/catch), causing queries to retain their original lowercase casing instead of being uppercased — leading to non-deterministic test failures.
  • Adds a mutex (Sema(1)) around formatQuery to serialize prettier calls, making output deterministic.

Test plan

  • All 153 tests pass locally
  • Specifically verified remote.test.ts (8 tests) and query-optimizer.test.ts (5 tests) — both previously failing in the release CI job

🤖 Generated with Claude Code

veksen and others added 2 commits April 2, 2026 19:48
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query Doctor Analysis

View full run details

82 queries analyzed

2 pre-existing issues

Using assumed statistics (10000 rows/table). For better results, sync production stats.

@veksen veksen requested a review from Xetera April 3, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant