Skip to content

test: serialize Steady-backed Jest runs#1976

Open
HAYDEN-OAI wants to merge 1 commit into
mainfrom
dev/hayden/fix-mock-server-flake
Open

test: serialize Steady-backed Jest runs#1976
HAYDEN-OAI wants to merge 1 commit into
mainfrom
dev/hayden/fix-mock-server-flake

Conversation

@HAYDEN-OAI

Copy link
Copy Markdown
Contributor

Summary

  • Default the local Steady-backed test harness to run Jest with --runInBand.
  • Preserve explicit Jest worker settings such as --maxWorkers or --runInBand when callers provide them.
  • Leave generated API resource tests and SDK resource code untouched.

Root Cause

Two unrelated PRs saw a single multipart skills request fail with APIConnectionError: Connection error. while expecting Steady to return a 404 for /_stainless_unknown_path. The failures happened under Jest's parallel worker mode while many tests shared one local Steady process on port 4010, and reruns passed. The rest of each job continued to communicate with Steady, which points to intermittent mock-server request handling under concurrency rather than product code.

Impact

The default ./scripts/test path is now more stable in CI and local runs that use the built-in Steady server. Developers can still opt into parallel workers explicitly when they are testing against another server or want to stress the harness.

Validation

  • bash -n scripts/test
  • ./scripts/test tests/api-resources/skills/skills.test.ts tests/api-resources/skills/versions/versions.test.ts
  • ./scripts/test
  • ./scripts/test tests/api-resources/skills/skills.test.ts --maxWorkers=2
  • npx pnpm@11.5.1 run lint

@HAYDEN-OAI HAYDEN-OAI marked this pull request as ready for review July 6, 2026 20:54
@HAYDEN-OAI HAYDEN-OAI requested a review from a team as a code owner July 6, 2026 20:54
@openai-sdks

openai-sdks Bot commented Jul 6, 2026

Copy link
Copy Markdown

OkTest Summary

237/237 SDK tests passed in 10.949s for Node SDK PR #1976.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 191ms
tests/chat-completions-create.test.ts ✅ Passed 241ms
tests/chat-completions-stream.test.ts ✅ Passed 227ms
tests/files-content-binary.test.ts ✅ Passed 170ms
tests/files-create-multipart.test.ts ✅ Passed 134ms
tests/files-list-pagination.test.ts ✅ Passed 168ms
tests/initialize-config.test.ts ✅ Passed 198ms
tests/instance-isolation.test.ts ✅ Passed 104ms
tests/models-list.test.ts ✅ Passed 159ms
tests/responses-background-lifecycle.test.ts ✅ Passed 259ms
tests/responses-body-method-errors.test.ts ✅ Passed 399ms
tests/responses-cancel-timeout.test.ts ✅ Passed 317ms
tests/responses-cancel.test.ts ✅ Passed 247ms
tests/responses-compact-retries.test.ts ✅ Passed 237ms
tests/responses-compact.test.ts ✅ Passed 170ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 164ms
tests/responses-create-advanced.test.ts ✅ Passed 175ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.179s
tests/responses-create-errors.test.ts ✅ Passed 241ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 198ms
tests/responses-create-retries.test.ts ✅ Passed 269ms
tests/responses-create-stream-failures.test.ts ✅ Passed 200ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 2.174s
tests/responses-create-stream-wire.test.ts ✅ Passed 2.635s
tests/responses-create-stream.test.ts ✅ Passed 164ms
tests/responses-create-terminal-states.test.ts ✅ Passed 258ms
tests/responses-create-timeout.test.ts ✅ Passed 283ms
tests/responses-create.test.ts ✅ Passed 138ms
tests/responses-delete.test.ts ✅ Passed 142ms
tests/responses-input-items-errors.test.ts ✅ Passed 199ms
tests/responses-input-items-list.test.ts ✅ Passed 173ms
tests/responses-input-items-options.test.ts ✅ Passed 187ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 230ms
tests/responses-input-tokens-count.test.ts ✅ Passed 226ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.198s
tests/responses-not-found-errors.test.ts ✅ Passed 374ms
tests/responses-parse.test.ts ✅ Passed 220ms
tests/responses-retrieve-retries.test.ts ✅ Passed 268ms
tests/responses-retrieve.test.ts ✅ Passed 210ms
tests/responses-stored-method-errors.test.ts ✅ Passed 687ms
tests/retry-behavior.test.ts ✅ Passed 3.085s
tests/sdk-error-shape.test.ts ✅ Passed 359ms

View OkTest run #28822581713

SDK merge (247bea600220) · head (d46e7d78ce3a) · base (95b54e589491) · OkTest (7fc645091b1a)

@HAYDEN-OAI HAYDEN-OAI requested a review from apcha-oai July 6, 2026 21:00
Comment thread scripts/test
function has_jest_worker_flag() {
for arg in "$@"; do
case "$arg" in
--runInBand|--runInBand=*|--maxWorkers|--maxWorkers=*|-i|-w)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This misses other Jest-supported spellings of the same worker option. Jest 29.7 accepts --max-workers=2, -w=2, and -w2, but each falls through this matcher, so the wrapper prepends --runInBand; Jest then exits 1 with Both --runInBand and --maxWorkers were specified, only one is allowed. I reproduced that directly with ./scripts/test --showConfig --max-workers=2, while invoking Jest directly with each spelling reports maxWorkers: 2. Please recognize the dashed long form and attached short forms (and add wrapper-level regression coverage) so valid existing pnpm test -- ... invocations do not break.

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I validated the intended serialization behavior and the motivating failure, but found one backward-compatibility defect in the worker-flag detection (inline).

Evidence reviewed:

  • The PR has no linked GitHub issue. I traced the motivating failure to CI run 28808742182 (Node 20): the full parallel suite failed only tests/api-resources/skills/skills.test.ts, receiving APIConnectionError: Connection error. instead of NotFoundError; 109 other suites / 1,141 tests passed, including the Skills versions suite. This matches an intermittent shared-Steady failure rather than an SDK behavior regression.
  • On the base commit, repeated local parallel stress runs of the non-Bedrock suite passed (the flake did not reproduce locally, consistent with its intermittent nature).
  • On this head, bash -n scripts/test passed. The targeted Skills and Skills Versions run passed (2 suites, 16 tests). ./scripts/test --showConfig reports maxWorkers: 1; explicit --maxWorkers=2 and -w 2 both remain at maxWorkers: 2. Current CI is green across Node 20/22/24/26.2, build, lint, breaking-change detection, ecosystem, CodeQL, and OkTest 237/237.
  • A complete local run reached all suites but was not a clean signal because the shared checkout lacked the optional AWS dependency used by two Bedrock test files; all 108 other suites passed, including both Skills suites. This is environmental and unrelated to the patch.

Compatibility assessment: this changes only the repository test harness, not published runtime/types/API behavior. Default local/CI tests become serial (slower but safer), while TEST_API_BASE_URL continues to preserve Jest defaults. The blocking issue is that valid Jest aliases --max-workers=2, -w=2, and -w2 are not detected. The wrapper injects --runInBand, and Jest rejects the invocation because both worker modes are present. Since preserving explicit worker settings is an explicit contract of this PR and these invocations worked before, please cover all accepted worker-option spellings before merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants