From 84b74beed84dd3b7ec9c9c329dde5f053f46d0a0 Mon Sep 17 00:00:00 2001 From: "peco-engineer-bot[bot]" Date: Thu, 26 Nov 2026 17:26:07 +0000 Subject: [PATCH] learn: retrospective learnings Signed-off-by: peco-engineer-bot[bot] --- .claude/knowledge/journal/2026-11-26.md | 9 +++++++++ .claude/knowledge/lessons.md | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .claude/knowledge/journal/2026-11-26.md diff --git a/.claude/knowledge/journal/2026-11-26.md b/.claude/knowledge/journal/2026-11-26.md new file mode 100644 index 00000000..0ec799df --- /dev/null +++ b/.claude/knowledge/journal/2026-11-26.md @@ -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. diff --git a/.claude/knowledge/lessons.md b/.claude/knowledge/lessons.md index 0b3ae3f9..6d0a6ccf 100644 --- a/.claude/knowledge/lessons.md +++ b/.claude/knowledge/lessons.md @@ -1,6 +1,6 @@ # Lessons - + ## 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. @@ -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. ## 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. @@ -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.