Skip to content

test(ai-sandbox-vercel): stop the large-file write test timing out in CI - #2323

Merged
tombeckenham merged 1 commit into
mainfrom
2322-fix-tanstackai-sandbox-verceltestcoverage
Dec 4, 2026
Merged

tombeckenham merged 1 commit into
mainfrom
2322-fix-tanstackai-sandbox-verceltestcoverage

Conversation

@tombeckenham

@tombeckenham tombeckenham commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

@tanstack/ai-sandbox-vercel:test:coverage is red on main because one test times out on a busy CI runner. The test compared a 1 MiB Uint8Array one byte at a time. This PR compares that payload by reference, so the test takes 2 ms.

🎯 Changes

  • packages/ai-sandbox-vercel/tests/fs-write.test.ts: the large-file test reads writeFiles.mock.calls[0] and uses toBe for the payload. It still checks one call, the path, and the options.
  • No docs: the change is not user-facing.
  • No changeset: only a test file changed. No published code changed.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.
  • Docs: I updated docs/ for this change, or this change is not user-facing.
  • Changeset: I added a changeset (pnpm changeset), or this PR does not change a published package.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Root cause

Issue. The Coverage workflow on main fails at @tanstack/ai-sandbox-vercel:test:coverage. The failed test is VercelHandle.fs.write > uploads a large file in one writeFiles call, with no exec, with Error: Test timed out in 5000ms. The failure is intermittent: 3 of the last 12 runs on main passed.

Cause. expect(writeFiles).toHaveBeenCalledWith([{ path, content: payload }], ...) does a deep comparison. For a Uint8Array, Vitest compares each element, here 1,048,576 of them. That takes about 0.9 s on a fast laptop and 1.6 s with v8 coverage. On a 4-core runner that runs 106 tasks, it takes more than the 5 s test timeout. The test arrived in #2256.

Fix. The handle passes the caller's array to writeFiles without a copy, so the test compares the payload with toBe. That is one reference comparison.

Possible alternatives

  • Longer timeout for this test. Pass a timeout as the last argument of it. The test stays slow, and a slower runner can still exceed the new limit.
  • Smaller payload. Use a few KiB. The test name says "large file", and the comparison stays linear in the payload size.

Testing

Commands run.

  • pnpm exec nx run-many --targets=test:types,test:oxlint,test:lib,test:coverage --projects=@tanstack/ai-sandbox-vercel: 11 tasks passed.
  • pnpm exec oxfmt --check packages/ai-sandbox-vercel/tests/fs-write.test.ts: passed.
  • I did not run the full pnpm test:pr. The diff is one test file in one package. CI runs the rest.

Repro. A local machine is too fast to reach 5 s, so the repro uses a 300 ms timeout. The same command ran against the test file from main (f18a309f1) and the test file from this branch.

main:

$ pnpm exec vitest run tests/fs-write.main.test.ts --testTimeout=300
     × uploads a large file in one writeFiles call, with no exec 1025ms
 FAIL  tests/fs-write.main.test.ts > VercelHandle.fs.write > uploads a large file in one writeFiles call, with no exec
Error: Test timed out in 300ms.
 Test Files  1 failed (1)
      Tests  1 failed | 3 passed (4)

This branch:

$ pnpm exec vitest run tests/fs-write.test.ts --testTimeout=300
 Test Files  1 passed (1)
      Tests  4 passed (4)

Manual test.

  1. On main, go to packages/ai-sandbox-vercel and run pnpm exec vitest run tests/fs-write.test.ts --testTimeout=300. The first test times out.
  2. Check out this branch and run the same command. All 4 tests pass.
  3. Run pnpm exec vitest run tests/fs-write.test.ts --reporter=verbose. The first test takes about 2 ms.

How this PR makes testing easy. The changed test is the artifact. No new test or script is necessary.

Linked issues

Fixes #2322

Risk / rollback

Low. Only a test changed. If the handle starts to copy the payload, the toBe assertion fails, which is the correct signal for this test. To undo, revert the PR.

Fixes #2322

Summary by CodeRabbit

  • Tests
    • Updated validation for large-file writes to check the recorded file path, payload identity, and write options separately. This keeps the test focused on the relevant details of the write operation.

toHaveBeenCalledWith compared the 1 MiB Uint8Array one byte at a time.
That took about 1 s locally and more than the 5 s test timeout on a busy
CI runner, so @tanstack/ai-sandbox-vercel:test:coverage was red on main.

Fixes #2322
@tombeckenham tombeckenham linked an issue Dec 4, 2026 that may be closed by this pull request
@changeset-bot

changeset-bot Bot commented Dec 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 14dbfc9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@nx-cloud

nx-cloud Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 14dbfc9

Command Status Duration Result
nx run-many --targets=build --exclude=examples/... ✅ Succeeded 6s View ↗

💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-12-04 02:24:52 UTC

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Coverage

✅ Coverage held across 1 compared package(s).

Each package is measured twice in this job — on this PR and on its merge-base with main — and compared. A metric fails only when it is at or above 60% on the merge-base and under 60% on this PR. Other drops are listed but do not fail. Packages your PR doesn't affect are not measured and not listed.

package statements branches functions lines
ai-sandbox-vercel 61.35% (0.00) 61.60% (0.00) 50.00% (0.00) 63.04% (0.00) ok

@pkg-pr-new

pkg-pr-new Bot commented Dec 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

@tanstack/ai

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai@2323

@tanstack/ai-acp

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-acp@2323

@tanstack/ai-angular

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-angular@2323

@tanstack/ai-anthropic

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-anthropic@2323

@tanstack/ai-bedrock

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-bedrock@2323

@tanstack/ai-byteplus

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-byteplus@2323

@tanstack/ai-cartesia

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cartesia@2323

@tanstack/ai-claude-code

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-claude-code@2323

@tanstack/ai-client

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-client@2323

@tanstack/ai-cloudflare

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cloudflare@2323

@tanstack/ai-code-mode

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode@2323

@tanstack/ai-code-mode-snippets

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode-snippets@2323

@tanstack/ai-codex

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-codex@2323

@tanstack/ai-cohere

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cohere@2323

@tanstack/ai-compaction

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-compaction@2323

@tanstack/ai-computer-local

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-computer-local@2323

@tanstack/ai-computer-playwright

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-computer-playwright@2323

@tanstack/ai-computer-sandbox

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-computer-sandbox@2323

@tanstack/ai-computer-use

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-computer-use@2323

@tanstack/ai-devtools-core

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-devtools-core@2323

@tanstack/ai-durable-stream

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-durable-stream@2323

@tanstack/ai-effect

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-effect@2323

@tanstack/ai-elevenlabs

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-elevenlabs@2323

@tanstack/ai-event-client

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-event-client@2323

@tanstack/ai-fal

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-fal@2323

@tanstack/ai-gemini

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-gemini@2323

@tanstack/ai-grok

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok@2323

@tanstack/ai-grok-build

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok-build@2323

@tanstack/ai-groq

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-groq@2323

@tanstack/ai-harness

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-harness@2323

@tanstack/ai-harness-cli

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-harness-cli@2323

@tanstack/ai-isolate-cloudflare

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-cloudflare@2323

@tanstack/ai-isolate-daytona

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-daytona@2323

@tanstack/ai-isolate-e2b

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-e2b@2323

@tanstack/ai-isolate-node

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-node@2323

@tanstack/ai-isolate-quickjs

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs@2323

@tanstack/ai-isolate-quickjs-bun

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs-bun@2323

@tanstack/ai-llmgateway

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-llmgateway@2323

@tanstack/ai-lovable

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-lovable@2323

@tanstack/ai-mcp

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mcp@2323

@tanstack/ai-mcp-sandbox

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mcp-sandbox@2323

@tanstack/ai-memory

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-memory@2323

@tanstack/ai-meshy

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-meshy@2323

@tanstack/ai-mistral

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mistral@2323

@tanstack/ai-muse

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-muse@2323

@tanstack/ai-neon

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-neon@2323

@tanstack/ai-octane

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-octane@2323

@tanstack/ai-ollama

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollama@2323

@tanstack/ai-ollaya

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollaya@2323

@tanstack/ai-openai

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openai@2323

@tanstack/ai-opencode

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-opencode@2323

@tanstack/ai-openrouter

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openrouter@2323

@tanstack/ai-optimize

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-optimize@2323

@tanstack/ai-perplexity

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-perplexity@2323

@tanstack/ai-persistence

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-persistence@2323

@tanstack/ai-preact

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-preact@2323

@tanstack/ai-react

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react@2323

@tanstack/ai-reactor

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-reactor@2323

@tanstack/ai-remix

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-remix@2323

@tanstack/ai-sandbox

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox@2323

@tanstack/ai-sandbox-blaxel

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-blaxel@2323

@tanstack/ai-sandbox-boxd

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-boxd@2323

@tanstack/ai-sandbox-cloudflare

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-cloudflare@2323

@tanstack/ai-sandbox-daytona

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-daytona@2323

@tanstack/ai-sandbox-docker

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-docker@2323

@tanstack/ai-sandbox-e2b

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-e2b@2323

@tanstack/ai-sandbox-local-process

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-local-process@2323

@tanstack/ai-sandbox-railway

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-railway@2323

@tanstack/ai-sandbox-sprites

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-sprites@2323

@tanstack/ai-sandbox-upstash-box

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-upstash-box@2323

@tanstack/ai-sandbox-vercel

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-vercel@2323

@tanstack/ai-skills

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-skills@2323

@tanstack/ai-solid

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid@2323

@tanstack/ai-svelte

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-svelte@2323

@tanstack/ai-tripo

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-tripo@2323

@tanstack/ai-typesafe

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-typesafe@2323

@tanstack/ai-uthana

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-uthana@2323

@tanstack/ai-utils

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-utils@2323

@tanstack/ai-vercel-compat

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vercel-compat@2323

@tanstack/ai-vercel-gateway

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vercel-gateway@2323

@tanstack/ai-vertex

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vertex@2323

@tanstack/ai-vue

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue@2323

@tanstack/ai-worldlabs

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-worldlabs@2323

@tanstack/ai-zai

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-zai@2323

@tanstack/openai-base

npm i https://pkg.pr.new/TanStack/ai/@tanstack/openai-base@2323

@tanstack/preact-ai-devtools

npm i https://pkg.pr.new/TanStack/ai/@tanstack/preact-ai-devtools@2323

@tanstack/react-ai-devtools

npm i https://pkg.pr.new/TanStack/ai/@tanstack/react-ai-devtools@2323

@tanstack/solid-ai-devtools

npm i https://pkg.pr.new/TanStack/ai/@tanstack/solid-ai-devtools@2323

@tanstack/svelte-ai-devtools

npm i https://pkg.pr.new/TanStack/ai/@tanstack/svelte-ai-devtools@2323

commit: 14dbfc9

@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The large-file write test now checks the recorded writeFiles call with separate assertions for the file path, payload identity, and signal options.

Changes: Large-file write test

Layer / File(s) Summary
Recorded writeFiles assertions
packages/ai-sandbox-vercel/tests/fs-write.test.ts
The test checks the recorded file count, resolved path, payload object identity, and { signal: undefined } options. It no longer uses whole-call equality for the large payload.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Possibly related PRs

  • TanStack/ai#2256: It introduced the writeFiles behavior that the large-file test continues to verify.

Suggested reviewers: jbpionnier, alemtuzlak

Merge Risk: Minimal · up to 14dbf

This is a test-only change that makes a large-file write test avoid timing out. It has no production impact and is safe to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the test package and the fix (stopping the large-file write test from timing out in CI). This matches the main change: the test now compares the payload by reference instead of deep-co…
Description check Passed The description follows the repository template. It has the Changes section, the checklist, and the Release Impact section. It also adds root cause, alternatives, testing commands, a repro, a manual t…
Linked Issues check Passed Issue #2322 is a direct link. Its only requirement is that @tanstack/ai-sandbox-vercel:test:coverage passes on main. The issue gives no root cause. The PR attributes the failure to the large-file …
Out of Scope Changes check Passed The whole-PR diff against merge base f18a309f1 touches only packages/ai-sandbox-vercel/tests/fs-write.test.ts, in the large-file test. No source, docs, or published package files changed. The chan…
Full details: Title check

Explanation

The title names the test package and the fix (stopping the large-file write test from timing out in CI). This matches the main change: the test now compares the payload by reference instead of deep-comparing every byte. The title is short, specific, and in one sentence. It does not mention the reference-comparison approach, but it does not need to.

Full details: Description check

Explanation

The description follows the repository template. It has the Changes section, the checklist, and the Release Impact section. It also adds root cause, alternatives, testing commands, a repro, a manual test, linked issue, and risk notes. The first checklist item is marked, and the test-run item is unchecked with a note that the full test:pr was not run. The 'Docs' and 'Changeset' boxes are checked, and the Changes section explains why no docs or changeset are needed. Minor gaps: the Changes section lists the file change, and the checklist includes items that are not fully aligned with the stated rationale (the Docs and Changeset items are ticked while the Changes section says 'No docs' and 'No changeset'). These are non-critical.

Full details: Linked Issues check

Explanation

Issue #2322 is a direct link. Its only requirement is that @tanstack/ai-sandbox-vercel:test:coverage passes on main. The issue gives no root cause. The PR attributes the failure to the large-file test in packages/ai-sandbox-vercel/tests/fs-write.test.ts timing out. The diff replaces expect(writeFiles).toHaveBeenCalledWith([...], { signal: undefined }), a deep comparison of a 1 MiB Uint8Array, with writeFiles.mock.calls[0] checks: toHaveLength(1), path toBe, content toBe(payload), and options toEqual({ signal: undefined }). The call count check (toHaveBeenCalledTimes(1)) is kept. Source packages/ai-sandbox-vercel/src/handle.ts fs.write passes content: data to sandbox.writeFiles without a copy, so the reference assertion holds at the reviewed head. The fix is a coding change that addresses the failing test. CI results were not available, so the green status on main is not independently confirmed.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against merge base f18a309f1 touches only packages/ai-sandbox-vercel/tests/fs-write.test.ts, in the large-file test. No source, docs, or published package files changed. The change directly supports issue #2322. The weaker check on payload identity is intentional and is documented in the PR and in a code comment. No unrelated changes were found.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f18a309 and 14dbfc9.

Files selected for processing: 1

  • packages/ai-sandbox-vercel/tests/fs-write.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@tombeckenham
tombeckenham merged commit ee160dc into main Dec 4, 2026
15 checks passed
@tombeckenham
tombeckenham deleted the 2322-fix-tanstackai-sandbox-verceltestcoverage branch December 4, 2026 02:30
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.

fix @tanstack/ai-sandbox-vercel:test:coverage

1 participant