Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .claude/knowledge/journal/2026-11-26.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Learning journal 2026-11-26

### 2026-11-26: Resources, networking and performance — Detach node-fetch body-reader listeners after buffering on pooled TLS sockets
**Context:** PR #634 found that a keep-alive https.Agent socket holds on to its first ClientRequest through Node core listener closures. Through node-fetch's request closure, that request keeps the Response, the body-reader 'data'/'end'/'error' listeners and the whole downloaded CloudFetch buffer alive. The fix records which listeners response.buffer() adds and removes only those in a finally block, leaving earlier listeners, later listeners and the constructor's late-error handler in place.
**Rule:** After response.buffer() on a pooled HTTPS keep-alive connection, remove only the stream listeners that the read call itself added, in a finally block, and leave pre-existing and constructor error handlers attached so late stream errors are still handled.

### 2026-11-26: Test design — Prove memory release with WeakRef and forced GC over a real keep-alive HTTPS agent
**Context:** In PR #634 the retention bug appears only with real node-fetch, a keep-alive https.Agent and a TLS socket that stays pooled. Plain HTTP and stubbed Responses never show it. The test generates a localhost certificate with openssl and skips when openssl is missing. It holds the downloaded batch in a WeakRef, checks that the socket is still in agent.freeSockets, then forces GC (v8.setFlagsFromString('--expose-gc') plus vm.runInNewContext('gc')) and asserts deref() is undefined.
**Rule:** Test buffer-retention fixes end to end over a real keep-alive HTTPS server and agent: assert the socket is still pooled, then confirm with WeakRef plus forced GC that the payload was collected, because mocked responses or plain-HTTP tests cannot reproduce socket-pinned retention.
5 changes: 4 additions & 1 deletion .claude/knowledge/lessons.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Lessons

<!-- distilled-through: 2026-11-18 -->
<!-- distilled-through: 2026-11-26 -->

## Configuration and authentication
- L-0001 (3×, #457): Trace option support through DBSQLClient, auth adapters and each transport. Type declarations and class comments do not establish forwarding; shared preparation can precede backend-specific filtering.
Expand Down Expand Up @@ -36,6 +36,7 @@
- L-0029 (2×, #535 #594): Published-library overrides and lockfiles do not constrain downstream runtime dependencies. Fix declared ranges and test those ranges instead of claiming local overrides protect consumers.
- L-0030 (1×, #535): Security pins must not downgrade an already patched resolution; verify the advisory applies to the exact package.
- L-0031 (1×, #568): Put backend-shared code in neutral utilities. Preserve deep-import compatibility with deprecated re-export shims and smoke tests when moving modules.
- L-0079 (1×, #650): When condensing Unreleased changelog bullets into a release section, keep backend scope (Thrift/kernel-only), old-to-new defaults and forced user actions (re-login, config change); diff each against its original.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Low — L-0079 cites #650, but no 2026-11-24 journal file exists under .claude/knowledge/journal (only 11-18 and 11-26), so the lesson has no source in the repo. Add the missing journal entry, or drop L-0079 until its source lands.

🔀 Found by Claude Opus 5.5 · confirmed by the judge


## Errors, logging and telemetry
- L-0032 (1×, #514): Negative tests must assert the intended error shape or message so unrelated warehouse/auth failures cannot satisfy them.
Expand Down Expand Up @@ -68,6 +69,8 @@
- L-0057 (1×, #595): ProxyAgent needs TLS options at its top level. Verify proxy TLS/mTLS with a real CONNECT proxy and generated test certificate.
- L-0058 (1×, #577): Merge Arrow result rows with indexed concatChunks copies. Preserve provider batches and track owned leftover slices with offsets.
- L-0059 (1×, #611): Every auxiliary HTTP request, including OAuth, exchange and CloudFetch, must use the connection provider's getAgent to honor proxy/TLS settings.
- L-0080 (1×, #634): Pooled keep-alive TLS sockets pin the first request/Response. After response.buffer(), remove only listeners that read added, in finally; keep pre-existing and constructor late-error handlers.
- L-0081 (1×, #634): Test socket-pinned buffer retention over a real keep-alive HTTPS server/agent: assert socket stays in freeSockets, then WeakRef plus forced GC shows payload collected. Mocks and plain HTTP cannot reproduce it.

## Bot workflow and CI
- L-0060 (1×, #499): In bot workflows with both schedule and workflow_dispatch triggers, keep numeric input knobs string-typed and parse them downstream.
Expand Down
Loading