Repository navigation
fix: keep-alive Durable Object test harness and Studio teardown cleanup (#116) - #124
Merged
Merged
Conversation
#116) Miniflare 4's dispatchFetch sets undici's reset on every request, so each RemoteDoSqliteDriver call opened a TCP connection and left a local port in TIME_WAIT for 30 s. core-ts's store.test.ts reached ~16.3k TIME_WAIT sockets on macOS (16,384 ephemeral ports) and its Durable Object tail failed with EADDRNOTAVAIL (37 tests). createMiniflareDoSqlite() now sends calls straight to the entry socket that `await mf.ready` resolves to, over a node:http keep-alive Agent (4 sockets, 1 s idle close). A non-200 or a connection closed mid-response rejects with a plain Error, so a broken harness can never satisfy toThrow(StorageError). The public shape { driver(db?), dispose() } is unchanged. Two consecutive `pnpm --filter @cloudhal/core-ts test` runs: 988/988, no EADDRNOTAVAIL, TIME_WAIT peak ~4k (the D1 suites' startup burst). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Madraka <[email protected]>
#116) Studio's Vitest runs without globals, so Testing Library never registered its own cleanup. Files that do not call cleanup() kept their trees mounted; Base UI / Floating UI work committed outside act after the file ended, and React's passive flush (setImmediate) read window after happy-dom's teardown: "ReferenceError: window is not defined" (CI run 39959905949). setup.ts now runs cleanup() and vi.useRealTimers() after every test, and drains three setImmediate rounds after each file. components.test.tsx 10/10 clean; Studio 79 files, 1275 tests, no unhandled errors or act() warnings. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Madraka <[email protected]>
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #116.
Durable Object suites ran out of local ports (EADDRNOTAVAIL).
dispatchFetchsets undici'sreseton every request: it sendsconnection: close, so each call costs one new TCP connection and one local port in TIME_WAIT for 30 s.RemoteDoSqliteDriver(@cloudhal/storage/testing,createMiniflareDoSqlite) sends everySqlDrivercall that way, andSqlBlobStoreadds more.store.test.tspeaked at 16,344 TIME_WAIT sockets against 16,384 ephemeral ports, and 37 tests in its Durable Object tail failed withEADDRNOTAVAIL.await mf.readyresolves to, over anode:httpkeep-alive Agent (4 sockets, 1 s idle close).Error, so a broken harness can never satisfytoThrow(StorageError).{ driver(db?), dispose() }shape.@cloudhal/storage.Studio teardown flake: "window is not defined" (CI run 39959905949).
afterEach(cleanup).act, and React's passive flush ran after happy-dom had removedwindow.apps/studio/test/setup.tsnow runscleanup()andvi.useRealTimers()after every test, and drains threesetImmediaterounds after each file.Verification (local, sequential):
pnpm --filter @cloudhal/core-ts testEADDRNOTAVAIL), 337 sEADDRNOTAVAIL, ~350 s@cloudhal/storagedo-sqlite.test.tscomponents.test.tsx× 10Also run: biome,
typecheckfor storage and Studio,size:check,design:lint.Process: three independent reviewers checked the change, and two of their findings held up when a separate agent tried to refute them. Both are fixed in this PR: the mid-response close now settles the promise (reproduced with a small Node script), and harness HTTP failures are a plain
Error.Found along the way, not in this PR:
packages/mcp-server/src/render/checks/content.ts:72writes/\s/inside a template literal, so the in-page empty-section check tests for the letters, not whitespace.pnpm lint:fix"fixes" it to/s/.@cloudhal/storage/testing(and analytics, comments, schedules)./testingexports point at filesbuild-packages.tsskips.Checklist
pnpm checkandcargo test --workspacepass locally: the affected packages' typecheck and tests,size:checkanddesign:lintwere run one at a time (the owner's machine freezes when suites run in parallel). Fullpnpm checkand cargo were not run; no Rust or contract code changed..changeset/do-sqlite-keepalive.md(@cloudhal/storage: patch)git commit -s, DCO)🤖 Generated with Claude Code