Skip to content

test(service-cluster-redis): de-flake Redis wiring test (hoist cold imports)#1495

Merged
xuyushun441-sys merged 1 commit into
mainfrom
fix/redis-contract-test-import-timeout
Jun 1, 2026
Merged

test(service-cluster-redis): de-flake Redis wiring test (hoist cold imports)#1495
xuyushun441-sys merged 1 commit into
mainfrom
fix/redis-contract-test-import-timeout

Conversation

@xuyushun441-sys
Copy link
Copy Markdown
Contributor

Problem

Test Core intermittently fails on packages/services/service-cluster-redis/src/redis.contract.test.ts:

FAIL  Redis driver — wiring > exports a registerable driver and defineCluster picks it up
Error: Test timed out in 5000ms.
  ❯ redis.contract.test.ts:120  →  await import('./index.js') / await import('@objectstack/service-cluster')

Both wiring tests did two await import(...) inside the test body, under the default 5000ms timeout. On a cold/slow CI runner the one-time module load alone exceeds 5s, so the first test times out (the second only passed because the first had warmed the module cache). It's a flake, unrelated to any product code — it red-flagged #1488's Test Core, for instance.

Fix

Hoist both to top-level static imports:

import './index.js';                              // side-effect: registers the 'redis' driver
import { defineCluster } from '@objectstack/service-cluster';

import './index.js' still registers the driver as a side-effect at module eval, and defineCluster is a normal named export (service-cluster/src/index.ts). The cold import cost now lands once at file load, outside any per-test timeout. The two test bodies drop their local await import(...) lines; all assertions are unchanged.

Verified by inspection (pure import hoist; defineCluster is a confirmed named export, ./testing is a separate subpath import that's untouched). CI exercises the test.

🤖 Generated with Claude Code

…mports)

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 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Building Building Preview, Comment Jun 1, 2026 9:17pm

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling size/s labels Jun 1, 2026
@xuyushun441-sys xuyushun441-sys merged commit 5c4b93b into main Jun 1, 2026
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/s tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants