• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cameri / nostream / 46177186635
81%

Build:
DEFAULT BRANCH: main
Ran 28 Nov 2026 06:44PM UTC
Jobs 1
Files 353
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

28 Nov 2026 06:41PM UTC coverage: 78.51% (-1.9%) from 80.45%
46177186635

push

github

web-flow
fix(subscriptions): stop an aborted REQ from stranding its database connection (#1271)

Closes #1243.

A cherry-pick of `9f8c1668` from
[`AgrimTawani:fix/1243-req-cursor-release`](https://github.com/AgrimTawani/nostream/tree/fix/1243-req-cursor-release),
credited to @AgrimTawani, taken with `git cherry-pick -x`. The diff is
theirs, unchanged.

## What was wrong

A REQ's stored-events read is a knex stream over a pg cursor, and
aborting it (CLOSE, a closed socket, a rate-limit refusal) destroyed
that stream at once. Two windows make that unsafe:

- **Before knex holds a connection**: its close handler throws the
`__knexUid` TypeError the worker logs as "Unable to acquire connection",
and the connection the pool hands out afterwards runs the query into the
closed stream and is never released.
- **Before pg has submitted the query** (it queues behind a connection
still closing a previous cursor): the cursor close is a no-op, so pg
submits it afterwards and the backend sits `active` in `ClientRead` for
good while the pool hands the connection to queries that queue behind
it.

Each abort that lands in one of those windows costs a connection, the
windows widen as the pool fills, and once it is full every REQ on the
worker hangs.

## What the change does

`abortableQueryStream` (`src/utils/query-stream.ts`) is what the caller
pipes and aborts. The subscription still ends at once on abort — knex's
stream is destroyed only once knex has piped its query in and the cursor
is idle, done or errored — and a REQ aborted before its query starts no
longer starts one. Peer feeds stay streamed: no buffering is added, so
the `peer.subscription.maxLimit: 0` feed keeps its streaming behaviour.

## Evidence from the author

- New unit cases fail on the old code and pass on the new.
- Against Postgres 16, pool max 4, 600 REQs aborted at random points:
the old path leaves the pool full, the new one leaves it empty with
every connection usable.
- `lint`, `build:check` and the ... (continued)

6163 of 8476 branches covered (72.71%)

Branch coverage included in aggregate %.

41 of 41 new or added lines in 2 files covered. (100.0%)

309 existing lines in 38 files now uncovered.

12458 of 15242 relevant lines covered (81.73%)

689.7 hits per line

Coverage Regressions

Lines Coverage ∆ File
101
11.15
-47.84% src/utils/relay-probe/ws-protocol-probe.ts
30
67.53
-15.26% src/scripts/export-events.ts
20
9.62
-55.77% src/controllers/admission/get-admission-check-controller.ts
16
64.82
-13.57% src/import-events.ts
14
50.91
-38.18% src/utils/admin-health.ts
11
57.69
-42.31% src/factories/web-app-factory.ts
10
12.0
-56.0% src/controllers/invoices/get-invoice-status-controller.ts
9
17.5
-32.5% src/handlers/request-handlers/rate-limiter-middleware.ts
8
94.13
-2.64% src/repositories/event-repository.ts
7
33.33
-52.38% src/factories/rate-limiter-factory.ts
7
63.64
-21.21% src/utils/relay-probe/dns-probe.ts
6
57.14
-42.86% src/factories/controllers/post-invoice-controller-factory.ts
6
18.0
-12.0% src/utils/relay-probe/tls-probe.ts
5
64.06
-15.63% src/cache/client.ts
5
58.33
-41.67% src/factories/controllers/get-admission-check-controller-factory.ts
5
47.06
-13.73% src/factories/payments-processor-factory.ts
4
42.86
-57.14% src/handlers/request-handlers/nodeinfo-handler.ts
4
67.78
-4.44% src/utils/admin-notifications-settings.ts
4
57.14
-42.86% src/utils/monitor-identity.ts
3
75.7
-4.67% src/adapters/redis-adapter.ts
3
37.5
-12.5% src/app/worker.ts
3
57.14
-42.86% src/factories/controllers/get-invoice-status-controller-factory.ts
3
78.38
-21.62% src/routes/index.ts
3
59.06
-3.36% src/utils/relay-probe/nip11-probe.ts
2
82.19
-5.48% src/repositories/invite-code-repository.ts
2
77.27
-6.06% src/repositories/invoice-repository.ts
2
82.68
-3.9% src/repositories/peering-invoice-repository.ts
2
79.25
-11.32% src/repositories/peering-payment-repository.ts
2
84.52
-2.24% src/services/peering-buyer-service.ts
2
76.79
-2.68% src/utils/nip66-events.ts
2
85.11
-4.26% src/utils/relay-probe-targets.ts
2
87.6
-0.44% src/utils/settings-config.ts
1
85.71
-2.14% src/app/relay-monitor-worker.ts
1
83.33
-16.67% src/factories/controllers/lnbits-callback-controller-factory.ts
1
75.0
-25.0% src/factories/controllers/opennode-callback-controller-factory.ts
1
93.64
-0.85% src/services/event-import-service.ts
1
81.48
-5.56% src/utils/nip66-nip11-tags.ts
1
87.88
-6.06% src/utils/relay-probe-snapshot.ts
Jobs
ID Job ID Ran Files Coverage
1 Unit - 46177186635.1 28 Nov 2026 06:44PM UTC 353
78.51
GitHub Action Run
Source Files on build 46177186635
  • Tree
  • List 353
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #46177186635
  • 16f4babf on github
  • Prev Build on main (#46055586263)
  • Next Build on main (#46177345082)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc