Skip to content

Run vitest 4.1.11 in the browser shell (goal vitest-run-in-browser) - #353

Open
vanilla-wave wants to merge 161 commits into
mainfrom
t3code/vitest-run-browser
Open

vanilla-wave wants to merge 161 commits into
mainfrom
t3code/vitest-run-browser

Conversation

@vanilla-wave

@vanilla-wave vanilla-wave commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Delivered

npm install + vitest run for vitest 4.1.11 / vite 8.0.16 in the rifty shell, with the project's own vitest.config.ts and TypeScript tests. Both pools work (forks default, threads), the reporter prints real pass/fail lines, counts and the assertion diff, and the process exits with Node's code (fail → 1, fix → 0). npm test and --reporter=verbose behave the same. Compat page: docs/public/compat/vitest.md.

Every wall is fixed as a generic Node contract. There are no vitest/vite/cac-shaped patches.

# Node contract ADR
1 npm bare-version overrides ("vite": "8.0.16") 0451
2 node:path/posix builtin —
3 Node-own process members as named ESM imports —
4 named-loud fs.statfsSync / child_process.spawnSync / process.memoryUsage 0443
5 Function guard checks computed global keys at runtime (throws only for 'Function') 0444
6 Readable.pipe(process.stdout) never ends stdio —
7 uncaughtException / unhandledRejection / 'exit' / exit() ↔ exitCode 0445
8 live Worker = keepalive handle; run-to-completion exit; Node unref shape 0446
9 fork(..., {serialization:'advanced'}) as native structured clone 0448
10 vm lineOffset/columnOffset via one owned stack hook 0450
11 Worker.stdout/stderr; --require/--conditions/--experimental-import-meta-resolve on fork + Worker 0449
13 ref'd MessagePort keepalive (emnapi holds rolldown async work this way) 0447
12 acceptance e2e tests/e2e/vitest-run.spec.ts; loud vm.constants/http.Agent ceilings for unclaimed modes 0464

Outside the claim, modes fail loudly: jsdom/happy-dom, coverage, browser mode and vm pools each hit a named NotImplementedError. Watch mode and other vite versions are ⚠️ unclaimed, with the observed boundary stated (user amendment, 2026-09-23).

Process

  • Each child passed an independent Contract+RED and Final+GREEN review. Verdicts are in docs/backlog/*/reference/*-{contract-red,final-green}.json.
  • Four regressions found after landing were fixed via rifty-fix, with a baseline, a RED test and a root fix each:
    • Workbench close race;
    • no-COI declared gap hidden behind a fatal exit;
    • no-COI exit statuses;
    • runBin timers/listeners surviving past process exit.
  • Whole-goal CLOSE review: PASS, goal_complete: true, 18/18 coverage. Binding verdict: docs/backlog/runtime-js/reference/vitest-run-in-browser-final-green.json @ 57f6117. An independent codex review found the runBin blocker, which is fixed.
  • User decisions, recorded in docs/backlog/runtime-js/reference/vitest-run-in-browser-evidence.md §Goal record:
    • I7 option A: watch mode and other vite versions are unclaimed; no bans.
    • Late-rejection option B: narrow the claim and track the gap in backlog.
  • Discoveries went to backlog drafts, each with a fresh RDY-6 check. Every overturned ADR clause had a DEC-2 review.
  • browser-unit CI Node is pinned to 24.16.0, the version of the frozen oracle rows (PR-4, reviewed).

Prior draft attempts #349, #351 and #352 were used as evidence only; no code was taken from them.

Test plan

  • pnpm pr:check 25/25 on the reviewed tree
  • CI green: unit, parity, browser-unit, no-COI, e2e light/heavy (incl. vitest-run.spec.ts), prod, hosted
  • pnpm check:pass-binding OK

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

@vanilla-wave
vanilla-wave marked this pull request as ready for review September 25, 2026 10:19
@greptile-apps

greptile-apps Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[High risk] Closes vitest-in-browser goal; updates build and runtime architecture.

The PR needs the registry-URL requirement satisfied before merging; the Worker constructor listener cleanup is a non-blocking improvement.

Findings

  1. P2 Hardcoded npm registry URL ▶

Summary

The PR adds browser-shell support for vitest run with vitest 4.1.11 and Vite 8.0.16, backed by changes across npm resolution, Node process and worker contracts, IPC, module loading, and acceptance tests.

  • The npm override probe needs an environment-configured registry URL.
  • Worker construction should not leave stdio pipe listeners behind when validation fails.

Reviews (1) · Last reviewed commit: "Bind vitest goal final verdict at the re..."

import { tmpdir } from 'node:os';
import { join } from 'node:path';

const REGISTRY = 'https://registry.npmjs.org/';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Hardcoded npm registry URL The new probe fixes the registry to https://registry.npmjs.org/ and passes that value to every spawned npm process, overriding any configured registry or mirror. The repository requires external URLs to come from environment configuration. This requirement must be satisfied before merging.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@greptile-apps

greptile-apps Bot commented Sep 25, 2026

Copy link
Copy Markdown

Comments Outside Diff

These findings sit on lines the diff does not cover, so they could not be posted inline. Each one leaves this list once its file changes.

  • P2 Stdio listeners survive failed construction packages/runtime-js/src/builtins/worker_threads.ts:134 ▶

    A kernel-backed Worker pipes its stdout and stderr to the owner before process-context and environment validation finishes. If that validation throws, construction stops without ending those streams or removing their listeners. Repeated invalid constructions can therefore accumulate unused listeners on the owner's streams.

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.

1 participant