Repository navigation
chore: stabilize CI — onboarding type error, flaky timeouts, and embedded-PGlite production builds #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: stabilize CI — onboarding type error, flaky timeouts, and embedded-PGlite production builds #59
Changes from all commits
b2d4f8f
9758465
be74811
7a0dd02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| import { defineConfig } from 'vitest/config' | ||
| export default defineConfig({ | ||
| test: { environment: 'node', include: ['tests/**/*.test.ts'] }, | ||
| test: { | ||
| environment: 'node', | ||
| testTimeout: 20_000, | ||
| include: ['tests/**/*.test.ts'], | ||
| }, | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,15 @@ export interface PgliteStorageOptions { | |
| dataDir?: string | ||
| /** Table/function name prefix, to share one database across CMS instances. */ | ||
| prefix?: string | ||
| /** | ||
| * How long a client checkout may wait before failing. Defaults to 30s for the | ||
| * embedded engine (vs the server default of 5s): PGlite is a single in-process | ||
| * connection served FIFO, so a cold WASM/initdb start or a concurrent holder | ||
| * (SSE stream, scheduled snapshot worker, a request transaction) can legitimately | ||
| * make the next waiter wait several seconds — a 5s cap turns that contention into | ||
| * spurious "acquisition timed out" failures under load. | ||
| */ | ||
| acquisitionTimeoutMs?: number | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -73,11 +82,13 @@ export function createPglitePool( | |
| // "cannot insert multiple commands into a prepared statement". | ||
| if (!values || values.length === 0) { | ||
| const results = await instance.exec(sql) | ||
| // oxlint-disable-next-line eslint-js/no-restricted-syntax -- PGlite's exec() returns its own Results[] shape with no structural overlap with R; narrow to the engine's row type. | ||
| const last = results[results.length - 1] as unknown as | ||
| | { rows?: Array<R>; command?: string } | ||
| | undefined | ||
| return { rows: last?.rows ?? [], command: last?.command } | ||
| } | ||
| // oxlint-disable-next-line eslint-js/no-restricted-syntax -- PGlite's query() result type doesn't structurally overlap with R; narrow to the engine's row type. | ||
| const result = (await instance.query<R>( | ||
| sql, | ||
| values as Array<unknown>, | ||
|
|
@@ -116,6 +127,7 @@ export function createPgliteStorage( | |
| return createPostgresStorage({ | ||
| pool, | ||
| migrationPool: pool, | ||
| acquisitionTimeoutMs: options.acquisitionTimeoutMs ?? 30_000, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reject or support timeouts beyond the Node timer limit. If a caller sets Reject values above
|
||
| ...(options.prefix ? { prefix: options.prefix } : {}), | ||
| }) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bound the health probe with a shorter timeout or an overall deadline.
healthy()calls the sharedrequesthelper. That helper now aborts after 30 seconds. If the server accepts connections but never responds, each of the 45 attempts waits the full 30 seconds, then sleeps 1 second. The smoke test then fails after about 23 minutes, instead of about 8 minutes with the previous 10-second timeout. The loop has no overall deadline, and the helper has no per-call timeout.Give health probes a separate, shorter timeout, or add an overall deadline to the polling loop. Keep the 30-second timeout for ordinary and MCP requests.