Skip to content

Keep the test servers' connections open for the whole run - #273

Merged
rostislavrotaru merged 3 commits into
mainfrom
dev5/30-kept-connections
Nov 30, 2026
Merged

rostislavrotaru merged 3 commits into
mainfrom
dev5/30-kept-connections

Conversation

@rostislavrotaru

@rostislavrotaru rostislavrotaru commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Issue: #30

The first of two steps; the second, Playwright 1.65.1, closes the issue.

Why

On Windows 11, Chromium gives each new connection a random local port, and that connect at times fails with net::ERR_NO_BUFFER_SPACE. When it does, every spec file importing the module it was for fails to import.

The test servers kept idle connections for Node's default of 5 seconds. So they closed most of the browser's connections between spec files, and the browser opened new ones, each a new chance to fail.

These counts come from full npm test runs on Windows 11, with Node's connection events logged:

Part of the run 5 s keep-alive 10 min keep-alive
Shared page 123 connects in 185 s; the server closed 110 after about 6 s idle 30, all at the page's start, none mid-run
Traced part 30 30
Isolated part 64 52
Whole job about 217 about 112

Change

  • tests/network/kept-connections.ts (new) adds KeptConnections, a Vite plugin. It sets each test server's keepAliveTimeout to 10 minutes, so the server keeps an idle connection past any gap in a run. Chromium closes a connection it has used after 5 minutes idle, so the server never closes one first.
  • tests/network/interfaces/i-vite-dev-server.ts (new) is the part of Vite's dev server the plugin reads: its httpServer, which is null in middleware mode.
  • vitest.config.mts adds the plugin to the list. Angular's builder gives the list to both the root server and the browser project.
  • tests/node/kept-connections.test.ts (new) starts a real Node HTTP server and reads the Keep-Alive header it answers with: timeout=5 before the plugin, timeout=600 after. A null httpServer is left alone.
  • tests/test-server-connections.spec.ts (new) fetches from the server the test page loads from and checks it answers Keep-Alive: timeout=600, so leaving the plugin out of the config, or the builder no longer passing it on, fails.
  • README.md explains the plugin and why it's there, next to the test server's address settings.

Decided in the brief: no retries, no longer timeouts, and no rerunning a failed import.

Checks

  • On Linux, macOS and Windows, kept-connections, test-server-connections, test-server-address, failed-module-requests and code-block-spans pass.
  • The scripts and spec type-checks pass on Linux.
  • Three mutants are killed: keeping the 5 s default, not setting the timeout at all, and leaving the plugin out of vitest.config.mts.

Agent: DEV5 (developer)
Agent-Model: Anthropic Opus 5.5, Medium

With Node's default keep-alive, 5 s, the test servers closed most of
the browser's connections between spec files, and the browser opened
new ones: a whole run on Windows 11 opened about 120 on the shared
page. On Windows each new connection takes a random local port, which
at times fails with net::ERR_NO_BUFFER_SPACE, and every spec file
importing the module it was for then failed to import.

The KeptConnections plugin keeps both servers' idle connections for
10 minutes, past any gap in a run, so the shared page opens about 30,
all at its start.

Issue: #30

Agent: DEV5 (developer)
Agent-Model: Anthropic Opus 5.5, Medium
@rostislavrotaru rostislavrotaru self-assigned this Nov 30, 2026
A Node response header can be a list, which the scripts type-check refused.

Agent: DEV5 (developer)
Agent-Model: Anthropic Opus 5.5, Medium
@rostislavrotaru

Copy link
Copy Markdown
Contributor Author

#273 at 30ebdb8: ready, #30 (the first of its two PRs).
Changed: a KeptConnections Vite plugin keeps both test servers' idle connections for 10 minutes, so a Windows run opens about 112 connections where it opened about 217.
Checks: kept-connections, test-server-address, failed-module-requests and code-block-spans passed on Linux, macOS and Windows, with type-checks clean and 2 mutants killed on Linux; CI passed. 1 commit behind main, no conflict.
Not checked: nothing open

Agent: DEV5 (developer)
Agent-Model: Anthropic Opus 5.5, Medium

@rostislavrotaru
rostislavrotaru marked this pull request as ready for review November 30, 2026 11:03

@rostislavrotaru rostislavrotaru left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed: #273 at 30ebdb8
Verdict: Changes needed
Findings: 0 Should fix, 1 Low, as line comments

Agent: REVIEW3 (reviewer)
Agent-Model: Anthropic Opus 5.5, Low

The unit test checked KeptConnections only on a server of its own, so
leaving the plugin out of the config, or the builder no longer passing
it on, kept every check green.

Agent: DEV5 (developer)
Agent-Model: Anthropic Opus 5.5, Medium
@rostislavrotaru

Copy link
Copy Markdown
Contributor Author

#273 at 4dc7e83: ready, #30 (the first of its two PRs).
Changed: tests/test-server-connections.spec.ts checks the test page's own server answers Keep-Alive: timeout=600; the thread is answered with the commit.
Checks: kept-connections, test-server-connections, test-server-address, failed-module-requests and code-block-spans passed on Linux, macOS and Windows, with type-checks clean and 3 mutants killed on Linux (one leaves the plugin out of the config); CI passed. 1 commit behind main, no conflict.
Not checked: nothing open

Agent: DEV5 (developer)
Agent-Model: Anthropic Opus 5.5, Medium

@rostislavrotaru rostislavrotaru left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed: #273 at 4dc7e83
Verdict: Approve
Findings: 0 Should fix, 0 Low, as line comments
Why it's right: the test servers now keep their connections open for the whole run, which stops the dropped-connection stalls. The new spec reads Keep-Alive: timeout=600 from the test page's own server and fails at timeout=5 without the plugin. REVIEW3's thread is fixed and resolved, and CI is green on every platform.

Agent: LEAD (lead)
Agent-Model: Anthropic Opus 5.5, High

@rostislavrotaru
rostislavrotaru merged commit 0e70b6e into main Nov 30, 2026
19 checks passed
@rostislavrotaru
rostislavrotaru deleted the dev5/30-kept-connections branch November 30, 2026 11:22
rostislavrotaru added a commit that referenced this pull request Nov 30, 2026
Closes #30

The second of the issue's two steps; the first, #273, keeps the test
servers' connections open, so a run opens about half as many.

## Why

On Windows 11, Chromium's `TcpPortRandomizationWin` feature gives each
new connection a random local port. That connect at times fails with
`net::ERR_NO_BUFFER_SPACE`, and every spec file importing the module it
was for then fails to import. Playwright 1.65.0 turns the feature off in
the Chromium it launches (microsoft/playwright#43605). We pinned 1.63.0.

## Change

- `src/noldova.ui.components.angular/package.json` and
`src/noldova.ui.components.angular.docs/package.json`: `playwright` goes
from 1.63.0 to 1.65.1.
- `package-lock.json`: `playwright` and `playwright-core` go to 1.65.1,
with the registry's tarball URLs and integrity hashes. Their
dependencies, engines (`node >=20`) and bins are unchanged, so nothing
else in the lockfile moves.

## Release notes reviewed: 1.64.0, 1.64.1, 1.65.0, 1.65.1

- The browser moves from Chromium 153.0.8010.12 (1.63.0) to
159.0.8154.6. It is still the headless shell, installed by the build's
`playwright install --only-shell chromium`.
- 1.64.0 adds WebMCP, video and screencast options, and
`testProject.default`; none is used here.
- 1.64.0's breaking changes:
- `screen` is now forwarded from device descriptors. Neither config uses
a device descriptor (`devices[...]`), so `window.screen` is unchanged.
- Elements inside a hidden iframe now count as hidden to actions and
visibility checks. Vitest runs each spec in a visible iframe on its test
page, so no spec's element becomes hidden.
- JSX now follows `tsconfig.json`, and `--update-snapshots=missing`
passes. Both are in Playwright's own test runner, which the kit doesn't
use.
- 1.64.1 fixes an Electron launch regression and a cross-origin redirect
abort when a route is registered; the kit registers no routes.
- 1.65.0's notable changes are in Playwright's own test runner (Bun,
reporters, test locks, `useDefineForClassFields` in its transpiler,
shard and location handling, `.css` imports), which the kit doesn't use:
Vitest runs the specs and only launches the browser through Playwright.
Of its library changes, cookie matching, proxy credentials and
`APIRequestContext` params aren't used; accessible names now leave out
text the browser doesn't render, which no spec reads through Playwright.
- 1.65.1 fixes two test-runner regressions (decorated classes with
static fields, Bun locations).
- Installation: the packages have no install scripts. 1.65.1 has been
published since 2026-11-13.

No look check moved: every spec in the run below passed unchanged.

## Checks

- On Linux, macOS and Windows, after `npm ci` and the Chromium 159
install, the pixel-reading specs (`settled-pixels`, `forced-highlights`,
`forced-spans`, `lines`), the screenshot specs (`screenshot.fixture`,
`short-screenshot-names`, `avatar.component`,
`configuration-table-row-hover`, `dialog.component`,
`diff-view.component`, `mention-field-chips`), `emulated-media` and the
network specs (`kept-connections`, `test-server-address`,
`failed-module-requests`, `code-block-spans`) pass: 276 tests in the
shared run and 38 in the isolated one, on each system.
- CI runs the whole suite on every target.
- The flake proof at this head, the whole suite 10 times on Windows x64
and 10 on Windows arm64, passed every run, with no
`net::ERR_NO_BUFFER_SPACE` logged.

Agent: DEV5 (developer)
Agent-Model: Anthropic Opus 5.5, Medium
rostislavrotaru added a commit to noldova-com/desktop that referenced this pull request Nov 30, 2026
Issue: #76

The first of two steps; the second, Playwright 1.65.1, closes the issue.
This ports noldova-com/ui-components#273.

## Cause, measured

On Windows 11, Chromium gives each new connection a random local port,
and that connect at times fails with `net::ERR_NO_BUFFER_SPACE`. When it
does, every spec file importing the module it was for fails to import.
The window test servers kept idle connections for Node's default of 5
seconds, so they closed the browser's connections between spec files,
and the browser opened new ones, each a new chance to fail.

These counts come from a whole window run (282 spec files) on a Windows
11 machine, with the server's connection events logged:

| Keep-alive | Connects | Closed by the server when idle | Tests |
|---|---|---|---|
| 5 s, Node's default | 61 | 40, a median of 6.0 s after their last
request | the new spec fails, the other 2534 pass |
| 10 min, this PR | 30, all at the page's start | 0 | 2535 pass |

## Change

- `src/noldova.desktop.window/scripts/angular/kept-connections.ts` (new)
adds `KeptConnections`, a Vite plugin. It sets each test server's
`keepAliveTimeout` to 10 minutes. Chromium closes a connection it has
used after 5 minutes idle, so the server never closes one first.
- `src/noldova.desktop.window/vitest.config.mts` adds it to `plugins`,
which Angular's builder gives to both the root server and the browser
project.
-
`src/noldova.desktop.window/scripts/angular/tests/kept-connections.test.ts`
(new) starts a real Node HTTP server and reads the `Keep-Alive` header
it answers with: `timeout=5` before the plugin, `timeout=600` after. A
null `httpServer` is left alone.
- `src/noldova.desktop.window/tests/test-server-connections.spec.ts`
(new) fetches the test page and checks its server answers `Keep-Alive:
timeout=600`. Leaving the plugin out of the config, or the builder no
longer passing it on, fails it.
- `README.md` explains the plugin, with the counts, next to the test
server's address.

### Differences from the source

- `kept-connections.ts` takes desktop's `IViteServer`
(`scripts/angular/interfaces/i-vite-server.ts`) instead of
ui-components' `IViteDevServer`, and lives in `scripts/angular` with the
window app's other plugins. It drops the source's comment, since the
README holds the explanation, as for the other plugins here.
- The node test's fake server is a `TestViteServer` with the
`config.logger` that `IViteServer` requires.
- The spec fetches `location.href`, as `test-server-address.spec.ts`
does here, instead of the kit's `styles.css`.

## Checks

- On Linux, macOS and Windows, after `npm run build`, the script test
and the window specs `test-server-connections`, `test-server-address`
and `failed-module-requests` pass.
- The Documents check passes on Linux.
- Three mutants are killed on Linux: keeping the 5 s default, not
setting the timeout at all, and leaving the plugin out of
`vitest.config.mts`.

Agent: DEV5 (developer)
Agent-Model: Anthropic Opus 5.5, Medium
rostislavrotaru added a commit that referenced this pull request Dec 1, 2026
Closes #286

Moves the kit to 0.0.48, with what has merged since 0.0.47, so apps can
take the binary file note and the path tooltip from #282, and the tab
marker's tone, close place and dot from #299.

## What changes

- `version.json` is at 0.0.48.
- `CHANGELOG.md` has the 0.0.48 section, one entry per change a consumer
or docs-site reader sees, from #303 (#299), #291 (#280), #281 (#275),
#285 (#282), #263 (#151), #250 (#245), #262 (#138, #223), #260 (#16),
#248 (#233), #258 (#18), #268 (#28), #255 (#234), #254 (#239), #256
(#236), #253 (#238), #252 (#160), #249 (#244), #242 (#231), #269 (#261)
and #259 (#26).
- Left out, as changing nothing the package or the docs site shows: #251
(the header's phone-bar rules written once, the same look), #247
(workflow pins), #264 and #277 (build scripts), #266 (example names and
their check), #267, #271, #272, #273, #274, #276, #289 and #290 (tests
and their tools), #279 and #295 (workflow pins).

## Checks

No test covers these two files. The product names check reads the new
section in CI; it names no product.

Agent: DEV2 (developer)
Agent-Model: Anthropic Opus 5.5, Medium
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