Skip to content

fix: release gate, packaging, dual-build instanceof, Mongo primary reads and Postgres upgrade error - #100

Merged
dillonstreator merged 9 commits into
mainfrom
chore/release-gate-packaging
Nov 28, 2026
Merged

dillonstreator merged 9 commits into
mainfrom
chore/release-gate-packaging

Conversation

@dillonstreator

@dillonstreator dillonstreator commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

What was wrong, and what changed

Each item is its own commit.

Finding Problem Change
SC-001 release.yml ran changeset publish without typecheck, build or tests, so a red main could ship. Write and OIDC permissions were workflow-wide. coverage.yml had no permissions. coverage.yml gains workflow_call and permissions: contents: read. release.yml has a test job (uses: ./.github/workflows/coverage.yml, secrets: inherit, read-only), and release needs: test. Write/OIDC permissions move to the release job; the workflow level is {}.
OSS-001 / DOC-003 README says "tested against Redis 8 and Valkey 8", but CI only ran Redis. CI starts valkey/valkey:8-alpine on 6380 and re-runs test/redis.test.ts against it.
TEST-001 (part) examples/pg was never typechecked. CI runs pnpm --filter ./examples/pg typecheck.
OSS-004 The CJS build inherited incremental with outDir dist/cjs, so every tarball shipped dist/tsconfig.cjs.tsbuildinfo (532 kB of 1.5 MB). tsBuildInfoFile: ./tsconfig.cjs.tsbuildinfo, which is already gitignored and removed by clean.
OSS-005 .DS_Store was tracked; repository.url used git://; the types badge linked to a nonexistent src/cache.ts. Untracked and ignored; git+https://; the badge links to src/index.ts.
API-003 (verified) With both builds loaded, a CommonJS ErrorUnprocessableEventHandler thrown into an ESM processor failed instanceof. It was retried to maxAttempts instead of dead-lettered, and a TxOBError's backoffUntil was ignored. Repro against dist/: 3 handler calls, dead after 3 attempts. Each error class has a Symbol.for("txob.<Name>") brand on its prototype and a Symbol.hasInstance that checks it. Subclasses keep the default instanceof. After: 1 call, dead immediately.
MongoDB secondary reads (verified) txob's collections inherited the client's read preference (confirmed: secondaryPreferred on the client makes collection.readPreference.mode === "secondaryPreferred"). Claims count leased deliveries and read back what they just leased, so a lagging secondary could break limits or drop claimed deliveries until their lease expired. client.db(name, { readPreference: "primary" }) for txob's collections. Read concern is unchanged: forcing majority could hide the claim's own writes under w: 1.
OPS-001 A Postgres table created before 0.6 failed every publish and claim with a bare column "defer_until" does not exist. insertEvent, claimEventsForFanout and claimDeliveries rethrow, with cause, as: "txob_events" has no defer_until column. txob 0.6 added it, and migrate() doesn't add columns to existing tables; run ALTER TABLE ... ADD COLUMN IF NOT EXISTS defer_until TIMESTAMPTZ (see MIGRATING.md). The README banner now points at the 0.6 migration too.
API-002 publish type-checks with a pool, Prisma's root client, or a Mongo session outside a transaction. The event is then committed on its own. Docs only: a warning under publish. A runtime guard isn't reliable. A pool is the documented way to publish a standalone event. Prisma's root client and tx are structurally the same. Mongo's session.inTransaction() is detectable, but sessions are also used for causal consistency without a transaction, and rejecting them would break code that works today.
RES-002 A handler that ignores its timeout signal keeps its lease. Documented behavior (per the verification). The README now says the delivery and its slot are held until the process exits, and the attempt counts on the next claim.
DOC-003 "Every write is conditional on the lease token" doesn't cover completeFanout. Reworded: delivery writes are fenced; fan-out is idempotent instead.
PERF-004 (verified) Each Redis claim walks every saturated key in one script. Measured on Redis 8: about 36 ms per claim with 10,000 saturated keys and about 270 ms with 50,000, during which the server serves nothing else. That's linear (about 5 µs per key) and would reach the default 5 s lua-time-limit around 1M keys. It is real but needs a data-structure change (e.g. a separate set of saturated keys), so this PR only documents it, with the numbers.

Compatibility

  • No change to stored data, schema or public types. Error classes have the same names and constructors. instanceof is now true for instances from the other build, which is the point.
  • release.yml: a release now waits for the full suite (about 4 minutes) and doesn't run if it fails. A Codecov upload failure doesn't fail the run (fail_ci_if_error is unset), so it can't block a release.
  • Changeset: patch.

How it was tested

Real backends in temporary containers: Postgres 17, MongoDB 9 replica set, Redis 8, Valkey 8, DynamoDB Local.

  • pnpm install --frozen-lockfile, pnpm test:prepare, pnpm typecheck, pnpm build, pnpm --filter ./examples/pg typecheck: pass.
  • Full suite: 606/606 passed, rebased onto main after fix: store event data as published and validate it in the form the store keeps #97 merged. Plus test/redis.test.ts against Valkey 8 (ioredis, node-redis, iovalkey): 109/109.
  • New tests, each of which fails with its src/ change reverted:
    • src/error.test.ts: errors from a second module instance (./error.js?copy) pass instanceof; subclasses keep normal semantics.
    • test/mongodb.test.ts: all txob collections read from the primary when the client is secondaryPreferred.
    • test/pg.test.ts: with defer_until dropped, publish, fan-out claim and delivery claim all throw the explanatory error.
  • pnpm pack --dry-run: no tsbuildinfo; 308 files, 0.98 MB unpacked (was 309 files, 1.50 MB).
  • actionlint: only the two existing warnings (actions/checkout@v2, codecov/codecov-action@v2).
  • The API-003 repro against the built ESM and CJS dist/: 3 handler calls before, 1 after.

For the reviewer to decide

  • Gating the release on the reusable test workflow means a release runs the whole matrix, Codecov upload included. If you'd rather have a lighter gate (typecheck, build and unit tests only), it's a small change.
  • API-002 stays docs-only, for the reasons above. A Mongo inTransaction() check could be added as opt-in if you want it.

Left out, with reasons

  • Pinning actions by SHA / bumping checkout@v2, codecov@v2, Dependabot: these are dependency/action upgrades, which the brief excludes.
  • Wider CI matrix (Node 20/24, PG 14, Mongo 8, peer lower bounds): not cheap. Only Valkey was added.
  • PERF-004 fix: needs a Lua data-structure redesign. Documented instead.
  • PERF-001/002/003, OBS-001, OSS-002 (SECURITY/CONTRIBUTING), CONS-004: not small and unambiguous, or not fixes (new policy files, index redesigns, lease semantics).
  • src/date.ts dead code, tag scheme, CHANGELOG 0.6 p-limit wording, MIGRATING 0.5 "Node 20.3+": historical text or harmless; editing released notes isn't worth the churn.
  • Source maps pointing at src/: fixing that means shipping src/ or inlining sources, which is a packaging choice for you.

tsconfig.cjs.json inherited incremental builds with outDir dist/cjs, so
tsc wrote its 532 kB tsconfig.cjs.tsbuildinfo into dist/ and every npm
tarball shipped it. Write it next to tsconfig.cjs.json instead, where
the clean script and .gitignore already expect it.
The release workflow published to npm without running anything, so a
red main could ship. It now calls the test workflow and only versions or
publishes once that passes; write and OIDC permissions are scoped to the
release job, and the test workflow runs with read-only contents.

The README says the Redis store is tested against Valkey 8, but CI only
ran Redis 8; run the Redis store tests against Valkey too. Also
typecheck examples/pg, which nothing checked.
…before 0.6

migrate() creates missing tables but doesn't add columns, so upgrading
from 0.5 without the documented ALTER TABLE failed every publish and
claim with a bare 'column "defer_until" does not exist'. Name the
table, the column and the statement to run, and point at MIGRATING.md.
…checks

When the ESM and CommonJS builds both load in one process, each has its
own error classes. A handler throwing the CommonJS
ErrorUnprocessableEventHandler into an ESM processor was retried until
maxAttempts instead of being dead-lettered at once, and a TxOBError's
backoffUntil was ignored. Brand the classes with registered symbols so
instanceof matches instances from either copy.
The collections inherited the client's read preference, so with
secondaryPreferred the claim's counts and its read-back of leased
deliveries could hit a lagging secondary: per-key and handler limits
could be exceeded and claimed deliveries could be missing from the
result until their lease expired.
… Redis keys

- publish type-checks with a pool, Prisma's root client or a MongoDB
  session outside a transaction; say plainly what happens then.
- A handler that ignores its timeout signal keeps its lease and slot
  until the process exits.
- Fan-out is idempotent rather than fenced by the lease token.
- Each Redis claim walks every key at its per-key limit; give measured
  numbers.
- Point the README banner at the 0.6 column migration and fix the
  types badge link.
@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.22222% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.04%. Comparing base (f550c3b) to head (1e3b98a).

Files with missing lines Patch % Lines
src/pg/store.ts 95.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #100   +/-   ##
=======================================
  Coverage   96.04%   96.04%           
=======================================
  Files          34       34           
  Lines        2478     2504   +26     
  Branches      497      504    +7     
=======================================
+ Hits         2380     2405   +25     
- Misses         81       82    +1     
  Partials       17       17           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dillonstreator
dillonstreator merged commit 00ec95a into main Nov 28, 2026
4 checks passed
@dillonstreator
dillonstreator deleted the chore/release-gate-packaging branch November 28, 2026 20:30
@github-actions github-actions Bot mentioned this pull request Nov 28, 2026
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