From 30aac21b419ddd58ee3ce3e5ff34d66961e78151 Mon Sep 17 00:00:00 2001 From: Joe Li Date: Wed, 27 Aug 2025 14:27:56 -0700 Subject: [PATCH 1/4] fix(tests): Mock MessageChannel to prevent Jest hanging from rc-overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: rc-overflow@1.4.1 (used by Ant Design v5 components) creates MessageChannel handles for responsive overflow detection that remain open after test completion, causing Jest to hang with "Jest did not exit one second after the test run has completed". Solution: Mock MessageChannel as undefined in test environment, forcing rc-overflow to use its built-in requestAnimationFrame fallback which Jest handles properly. Impact: - Fixes Jest hanging in shard 4 tests (ChartList, ControlPanelsContainer, etc.) - Test environment only - no production impact - Preserves all functional test coverage (JSDOM can't test visual overflow anyway) - Shard 4 now completes in ~200s instead of hanging indefinitely Documentation: - Comprehensive code comments with removal conditions - Added "Known Issues and Workarounds" section to development docs - Future developers can verify if still needed by running npm test -- --shard=4/8 Removal conditions: Can be removed when rc-overflow, Jest, or Ant Design properly handles MessageChannel cleanup in test environments. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- docs/docs/contributing/development.mdx | 18 ++++++++++++ .../spec/helpers/jsDomWithFetchAPI.ts | 29 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/docs/docs/contributing/development.mdx b/docs/docs/contributing/development.mdx index ee38ca763490..6ec04c3ba01d 100644 --- a/docs/docs/contributing/development.mdx +++ b/docs/docs/contributing/development.mdx @@ -747,6 +747,24 @@ To run a single test file: npm run test -- path/to/file.js ``` +#### Known Issues and Workarounds + +**Jest Test Hanging (MessageChannel Issue)** + +If Jest tests hang with "Jest did not exit one second after the test run has completed", this is likely due to the MessageChannel issue from rc-overflow (Ant Design v5 components). + +**Root Cause**: `rc-overflow@1.4.1` creates MessageChannel handles for responsive overflow detection that remain open after test completion. + +**Current Workaround**: MessageChannel is mocked as undefined in `spec/helpers/jsDomWithFetchAPI.ts`, forcing rc-overflow to use requestAnimationFrame fallback. + +**To verify if still needed**: Remove the MessageChannel mocking lines and run `npm test -- --shard=4/8`. If tests hang, the workaround is still required. + +**Future removal conditions**: This workaround can be removed when: +- rc-overflow updates to properly clean up MessagePorts in test environments +- Jest updates to handle MessageChannel/MessagePort cleanup better +- Ant Design switches away from rc-overflow +- We switch away from Ant Design v5 + ### Debugging Server App #### Local diff --git a/superset-frontend/spec/helpers/jsDomWithFetchAPI.ts b/superset-frontend/spec/helpers/jsDomWithFetchAPI.ts index c1c1238e76e0..c79fc54d30fa 100644 --- a/superset-frontend/spec/helpers/jsDomWithFetchAPI.ts +++ b/superset-frontend/spec/helpers/jsDomWithFetchAPI.ts @@ -31,5 +31,34 @@ export default class FixJSDOMEnvironment extends JSDOMEnvironment { this.global.Response = Response; this.global.AbortSignal = AbortSignal; this.global.AbortController = AbortController; + + // WORKAROUND: Mock MessageChannel to prevent Jest test hanging + // + // Issue: rc-overflow@1.4.1 (used by Ant Design v5 components: Select, Menu, Picker) + // creates MessageChannel handles for responsive overflow detection that remain + // open after test completion, causing Jest to hang with: + // "Jest did not exit one second after the test run has completed" + // + // Root Cause: Ant Design v5 upgrade (commit dd129fa40370c93da1d0d536be870a5f363364fb, PR #31590) + // introduced rc-overflow library which uses MessageChannel for micro-task scheduling + // + // Solution: Set MessageChannel to undefined forces rc-overflow to use its built-in + // requestAnimationFrame fallback, which Jest handles properly without hanging + // + // Impact: No functional test coverage loss - JSDOM can't test visual overflow anyway. + // All component logic (interactions, state, API calls) still tested normally. + // + // Future Removal Conditions: + // - rc-overflow updates to properly clean up MessagePorts in test environments + // - Jest updates to handle MessageChannel/MessagePort cleanup better + // - Ant Design switches away from rc-overflow + // - We switch away from Ant Design v5 + // + // To verify if still needed: Remove these lines and run `npm test -- --shard=4/8` + // If tests hang, the workaround is still required. + // + // Related: See PROJECT.md for full investigation details + this.global.MessageChannel = undefined as any; + this.global.MessagePort = undefined as any; } } From 1984d8e439e7c62d0fe516d78dc662994d34cc7d Mon Sep 17 00:00:00 2001 From: Joe Li Date: Wed, 27 Aug 2025 14:40:01 -0700 Subject: [PATCH 2/4] docs: Update UPDATING.md and development docs with PR #34871 reference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add concise entry to UPDATING.md following established patterns - Update development docs to reference PR instead of PROJECT.md - Remove PROJECT.md references since it's not checked into the repo 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- UPDATING.md | 1 + docs/docs/contributing/development.mdx | 2 ++ 2 files changed, 3 insertions(+) diff --git a/UPDATING.md b/UPDATING.md index a175f7f440bb..08cd483775e0 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -23,6 +23,7 @@ This file documents any backwards-incompatible changes in Superset and assists people when migrating to a new version. ## Next +- [34871](https://github.com/apache/superset/pull/34871): Fixed Jest test hanging issue from Ant Design v5 upgrade. MessageChannel is now mocked in test environment to prevent rc-overflow from causing Jest to hang. Test environment only - no production impact. - [34782](https://github.com/apache/superset/pull/34782): Dataset exports now include the dataset ID in their file name (similar to charts and dashboards). If managing assets as code, make sure to rename existing dataset YAMLs to include the ID (and avoid duplicated files). - [34536](https://github.com/apache/superset/pull/34536): The `ENVIRONMENT_TAG_CONFIG` color values have changed to support only Ant Design semantic colors. Update your `superset_config.py`: - Change `"error.base"` to just `"error"` after this PR diff --git a/docs/docs/contributing/development.mdx b/docs/docs/contributing/development.mdx index 6ec04c3ba01d..c811177624b5 100644 --- a/docs/docs/contributing/development.mdx +++ b/docs/docs/contributing/development.mdx @@ -765,6 +765,8 @@ If Jest tests hang with "Jest did not exit one second after the test run has com - Ant Design switches away from rc-overflow - We switch away from Ant Design v5 +**See**: [PR #34871](https://github.com/apache/superset/pull/34871) for full technical details. + ### Debugging Server App #### Local From b3b09e8e16eafbdf1ccfd3012ebdb01775e5bdce Mon Sep 17 00:00:00 2001 From: Joe Li Date: Wed, 27 Aug 2025 14:42:31 -0700 Subject: [PATCH 3/4] refactor: Simplify MessageChannel mocking comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make comment more concise and focused on essential information: - Clear purpose: prevent hanging Jest tests with rc-overflow - What it does: forces requestAnimationFrame fallback - When to remove: when rc-overflow cleans up properly - Reference to PR for full context 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../spec/helpers/jsDomWithFetchAPI.ts | 30 +++---------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/superset-frontend/spec/helpers/jsDomWithFetchAPI.ts b/superset-frontend/spec/helpers/jsDomWithFetchAPI.ts index c79fc54d30fa..81279356c35f 100644 --- a/superset-frontend/spec/helpers/jsDomWithFetchAPI.ts +++ b/superset-frontend/spec/helpers/jsDomWithFetchAPI.ts @@ -32,32 +32,10 @@ export default class FixJSDOMEnvironment extends JSDOMEnvironment { this.global.AbortSignal = AbortSignal; this.global.AbortController = AbortController; - // WORKAROUND: Mock MessageChannel to prevent Jest test hanging - // - // Issue: rc-overflow@1.4.1 (used by Ant Design v5 components: Select, Menu, Picker) - // creates MessageChannel handles for responsive overflow detection that remain - // open after test completion, causing Jest to hang with: - // "Jest did not exit one second after the test run has completed" - // - // Root Cause: Ant Design v5 upgrade (commit dd129fa40370c93da1d0d536be870a5f363364fb, PR #31590) - // introduced rc-overflow library which uses MessageChannel for micro-task scheduling - // - // Solution: Set MessageChannel to undefined forces rc-overflow to use its built-in - // requestAnimationFrame fallback, which Jest handles properly without hanging - // - // Impact: No functional test coverage loss - JSDOM can't test visual overflow anyway. - // All component logic (interactions, state, API calls) still tested normally. - // - // Future Removal Conditions: - // - rc-overflow updates to properly clean up MessagePorts in test environments - // - Jest updates to handle MessageChannel/MessagePort cleanup better - // - Ant Design switches away from rc-overflow - // - We switch away from Ant Design v5 - // - // To verify if still needed: Remove these lines and run `npm test -- --shard=4/8` - // If tests hang, the workaround is still required. - // - // Related: See PROJECT.md for full investigation details + // Mock MessageChannel to prevent hanging Jest tests with rc-overflow@1.4.1 + // Forces rc-overflow to use requestAnimationFrame fallback instead + // Can be removed when rc-overflow properly cleans up MessagePorts in test environments + // See: https://github.com/apache/superset/pull/34871 this.global.MessageChannel = undefined as any; this.global.MessagePort = undefined as any; } From 41875fd08fe631a95ce5a3967cd0380c59d0b571 Mon Sep 17 00:00:00 2001 From: Joe Li Date: Wed, 27 Aug 2025 22:12:16 -0700 Subject: [PATCH 4/4] chore: remove properties from global --- superset-frontend/spec/helpers/jsDomWithFetchAPI.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/superset-frontend/spec/helpers/jsDomWithFetchAPI.ts b/superset-frontend/spec/helpers/jsDomWithFetchAPI.ts index 81279356c35f..beff7da95271 100644 --- a/superset-frontend/spec/helpers/jsDomWithFetchAPI.ts +++ b/superset-frontend/spec/helpers/jsDomWithFetchAPI.ts @@ -36,7 +36,7 @@ export default class FixJSDOMEnvironment extends JSDOMEnvironment { // Forces rc-overflow to use requestAnimationFrame fallback instead // Can be removed when rc-overflow properly cleans up MessagePorts in test environments // See: https://github.com/apache/superset/pull/34871 - this.global.MessageChannel = undefined as any; - this.global.MessagePort = undefined as any; + delete (this.global as any).MessageChannel; + delete (this.global as any).MessagePort; } }