From 1465535ef3883fdc1dd7f9d57425300210b3a2d8 Mon Sep 17 00:00:00 2001 From: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com> Date: Tue, 2 Jun 2026 05:16:35 +0800 Subject: [PATCH] test(service-cluster-redis): de-flake Redis wiring test (hoist cold imports) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "Redis driver — wiring" tests did `await import('./index.js')` + `await import('@objectstack/service-cluster')` inside the test body, under the default 5000ms timeout. On a cold/slow CI runner the one-time module load exceeded 5s and the first test failed with "Test timed out in 5000ms" (the second only passed because the first warmed the module cache) — an intermittent red on Test Core unrelated to any product change. Hoist both to top-level static imports: `import './index.js'` still registers the 'redis' driver as a side-effect at module eval, and `defineCluster` is a normal named export. The import cost now lands once at file load, outside any per-test timeout. Test assertions are unchanged. Co-Authored-By: Claude Opus 4.8 --- .changeset/redis-wiring-test-stabilize.md | 4 ++++ .../service-cluster-redis/src/redis.contract.test.ts | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 .changeset/redis-wiring-test-stabilize.md diff --git a/.changeset/redis-wiring-test-stabilize.md b/.changeset/redis-wiring-test-stabilize.md new file mode 100644 index 000000000..9b94a4ce4 --- /dev/null +++ b/.changeset/redis-wiring-test-stabilize.md @@ -0,0 +1,4 @@ +--- +--- + +Test-only: stabilize the Redis driver wiring contract test (hoist imports out of the timed test body to fix a flaky 5s timeout on slow CI). diff --git a/packages/services/service-cluster-redis/src/redis.contract.test.ts b/packages/services/service-cluster-redis/src/redis.contract.test.ts index 5df85a7f6..5b955a43d 100644 --- a/packages/services/service-cluster-redis/src/redis.contract.test.ts +++ b/packages/services/service-cluster-redis/src/redis.contract.test.ts @@ -17,6 +17,14 @@ import { runKVContract, runCounterContract, } from '@objectstack/service-cluster/testing'; +// Load the driver entrypoint at module eval — importing it registers the +// 'redis' cluster driver as a side-effect, which `defineCluster({ driver: +// 'redis' })` then resolves. Doing this here (not via `await import()` inside +// the timed test bodies) keeps the one-time cold module-load cost out of the +// per-test 5s timeout — the wiring tests below were flaky on slow CI for +// exactly that reason (the first test paid the full import cost and timed out). +import './index.js'; +import { defineCluster } from '@objectstack/service-cluster'; import { RedisPubSub } from './pubsub.js'; import { RedisLock } from './lock.js'; @@ -118,8 +126,6 @@ describe('IPubSub contract — redis(mock)', () => { describe('Redis driver — wiring', () => { it('exports a registerable driver and defineCluster picks it up', async () => { - await import('./index.js'); - const { defineCluster } = await import('@objectstack/service-cluster'); const client = makeClient(); const cluster = defineCluster({ driver: 'redis', @@ -145,8 +151,6 @@ describe('Redis driver — wiring', () => { }); it('does NOT quit caller-owned client on close', async () => { - await import('./index.js'); - const { defineCluster } = await import('@objectstack/service-cluster'); const client = makeClient(); const cluster = defineCluster({ driver: 'redis',