Skip to content

refactor(service): Split bodies, clients, run config, recording files, and the JSON scan into files - #55

Merged
dcramer merged 1 commit into
mainfrom
refactor/service-split
Nov 5, 2026
Merged

dcramer merged 1 commit into
mainfrom
refactor/service-split

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Stacked on #54. Merge that first, then change the base to main.

This PR only moves code. It moves code out of server.ts, service.ts, recorder.ts and secrets.ts into 5 new files:

  • bodies.ts
  • clients.ts
  • run-config.ts
  • recording-file.ts
  • json-strings.ts

A compare of the code lines before and after shows only export/import changes and oxfmt line wraps. git range-diff gives = against the version that was checked before the last rebase.

It also updates docs:

  • the README "Files" map
  • the README text on idle tunnels: Node closes an idle tunnel between requests after about 5–6 s (keepAliveTimeout), not 10 min
  • the TELEMETRY table: roach.mode can be off, and roach.reason is on the metric too

Verification:

  • pnpm check passes on Node 24: 114 tests, lint clean, knip clean.
  • request-key.ts has no changes, and the pinned key tests pass.

via @dcramer.

--

View Session [Sentry]

@sentry-junior
sentry-junior Bot added this pull request to stack #56 November 5, 2026 17:29
Base automatically changed from fix/redaction-gaps-3 to main November 5, 2026 17:40
…, and the JSON scan into files

Move code out of the four largest files of the service at their feature
lines. The code does not change: a compare of the code lines before and
after, without imports, comments, and `export`, differs only in the line
breaks of three signatures that oxfmt wrapped.

- `server.ts` -> `bodies.ts` (request bodies, their limits, and the
  shared budget) and `clients.ts` (the PROXY protocol header and the
  address of a client).
- `service.ts` -> `run-config.ts` (the check of a run config, its limits,
  the tenant name, and the CI attributes).
- `recorder.ts` -> `recording-file.ts` (`toRecording`, `fromRecording`,
  and the decoding of compressed bodies).
- `secrets.ts` -> `json-strings.ts` (`scanStrings`, `decodeString`, and
  `parseJson`).

The docs also had drifted from the code:

- README said that an idle tunnel closes after 10 minutes. Between two
  requests, Node closes it after about 5 s (`keepAliveTimeout`), as a
  probe of a plain and a TLS tunnel shows. In a tunnel without TLS, Node
  removes the 10-minute limit after the first request. The README and
  the comment of `TUNNEL_IDLE_MS` now say so.
- TELEMETRY.md: `roach.mode` can be `off`, and `roach.reason` is on the
  `roach.request` metric too.
- README "Files" lists the new files.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
@dcramer
dcramer force-pushed the refactor/service-split branch from 6d99a19 to 5156054 Compare November 5, 2026 17:40
@dcramer
dcramer marked this pull request as ready for review November 5, 2026 17:40
@dcramer
dcramer merged commit fdffc6e into main Nov 5, 2026
14 checks passed
@dcramer
dcramer deleted the refactor/service-split branch November 5, 2026 17:41
sentry-junior Bot added a commit that referenced this pull request Nov 5, 2026
Check each path, limit, metric, attribute, and section against the code
after the service split (#55) and the client tidy (#57):

- README: name the `url` input of the action, the rule name limits, the
  length limit of run secrets, the full list of credential header names,
  what a recording keeps (method, redacted URL, `content-type` and
  `location`), the 500 misses that the stats keep, `http.request.method`
  on `roach.request` and `roach.upstream`, the 10 s limit of a PROXY
  header, the 201/400/401/429 answers of `POST /__roach/runs`, and the
  404 for a wrong run token.
- README: the service log gets the class, the code, and the GCS status of
  an error.
- README: shorten the one-time PROXY protocol rollout to the steady-state
  order: deploy the image, apply the config secret with `-target`, reset
  the VM, apply the rest.
- README: drop the cache list of "Sentry" that TELEMETRY.md repeats, and
  the repeat of the miss rule of "Misses" in "Service". Move the
  changing-keys query to TELEMETRY.md.
- README: list redaction.test.ts and packages/roach/tests/package.test.ts,
  and say that CI also runs coverage and packs the package.
- TELEMETRY: name server.ts as a source, add `roach.recordings`,
  `roach.written`, and `http.request.method`, and the log fields.
- AGENTS: the Image workflow runs `terraform validate`, not CI.
- service.ts and server.ts comments: the key worker is a process, and
  the keep-alive time is 5 s and 1 s more.

Only docs and comments change. The tunnel limits bullet stays as on
main, because the fix of the tunnel idle limit changes it.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
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