Skip to content

fix(tests): prevent SemanticLayerModal test from hanging indefinitely#39956

Closed
aminghadersohi wants to merge 1 commit into
apache:masterfrom
aminghadersohi:fix/semantic-layer-modal-test-hang
Closed

fix(tests): prevent SemanticLayerModal test from hanging indefinitely#39956
aminghadersohi wants to merge 1 commit into
apache:masterfrom
aminghadersohi:fix/semantic-layer-modal-test-hang

Conversation

@aminghadersohi
Copy link
Copy Markdown
Contributor

Summary

  • The SemanticLayerModal test introduced in feat: semantic layer extension #37815 hangs forever, causing shard 6 of the frontend test suite to time out after 3+ hours
  • The test uses fake timers to control a debounce, but our test environment patches out MessageChannel (to work around an rc-overflow issue). Without MessageChannel, React falls back to setTimeout for scheduling renders — and fake timers block those too, so React never re-renders and the test never finishes
  • Fix: tell Jest to auto-advance fake timers (advanceTimers: true), which unblocks React's render scheduling while still letting the test explicitly control the 500ms debounce
  • Also reorder the DatasetList.test.tsx cleanup to restore real timers before flushing async work, so a test failure mid-run can't cause the same kind of hang

Test plan

  • SemanticLayerModal.test.tsx passes in ~14s (was hanging indefinitely)
  • All 28 DatasetList.test.tsx tests pass
  • Shard 6/8 completes in CI without timeout

The SemanticLayerModal test called jest.useFakeTimers() which intercepts
setTimeout. Because the test environment disables MessageChannel (for
rc-overflow compatibility), React 18's scheduler falls back to setTimeout
for scheduling re-renders. With fake timers active, React can never
re-render, waitFor() can never be satisfied or time out, and the test
hangs indefinitely.

Fix by passing advanceTimers: true so React's scheduler timers auto-fire
while the 500ms debounce remains under explicit control.

Also reorder DatasetList.test.tsx afterEach to call jest.useRealTimers()
before the async flush, preventing a secondary deadlock if a loading
test throws while fake timers are active.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants