#3466 · SDK response method dispatch

Bug · High priority · Low effort · plugins · 2026-09-11

Base: b04091eca67bb463cce16b9bfa318660bd20ab69 · Issue

REPRODUCED · root-cause confidence: high

TL;DR

The SDK rejects while reading installer events when the server adapter replaces the global Response constructor. The response returned by the transport is native, but the SDK invokes the adapter prototype method on it. That method needs adapter-private state and throws. The same agent reproduced the exact exception in two trusted checkouts; no provider installation or live BB instance was used.

Claims vs findings

ClaimFinding
Native response reading throwsVerified twice with the installed Hono adapter and built SDK.
Wrapper-private state causes the failureVerified: adapter text() expects getResponseCache on its receiver.
Provider binary remains unchangedUnverified. The read occurs after the installer endpoint responds; this SDK exception alone does not establish whether the installer ran.
Reported historical runtime versionsUnverified; current trusted main was tested.

Environment

macOS, Node 22.22.3, pnpm 9.15.0, Hono node-server 1.19.14 from the frozen lockfile. First checkout: automation worktree at the recorded SHA. Second checkout: a clean temporary detached worktree at the same SHA. No ports, credentials, provider processes, or runtime data directories. Frozen installs succeeded using Corepack because the default pnpm launcher was broken. Full Turbo build passed (20 tasks); second checkout SDK build passed.

Minimal reproduction

  1. Check out the recorded commit of get-bb/bb.
  2. Run corepack pnpm install --frozen-lockfile --prefer-offline and corepack pnpm exec turbo run build --filter=@bb/sdk. Ensure subprocess pnpm uses Corepack if the host launcher is broken.
  3. Save repro.mjs and run node /path/to/repro.mjs from the repository root.

Expected: parsed installer event matches the supplied event. Actual in both checkouts:

TypeError: this[getResponseCache] is not a function
import { createRequire } from 'node:module';
import { pathToFileURL } from 'node:url';
import assert from 'node:assert/strict';
const root = process.cwd();
const require = createRequire(root + '/apps/server/package.json');
const { getRequestListener } = require('@hono/node-server');
const { createNodeBbSdk } = await import(pathToFileURL(root + '/packages/sdk/dist/node.js'));
const events = [{type:'error', provider:'test-provider', message:'installer evidence'}];
const response = new Response(events.map(JSON.stringify).join('\n') + '\n');
const originalResponse = globalThis.Response;
const originalRequest = globalThis.Request;
try {
  getRequestListener(() => new Response('unused'));
  const sdk = createNodeBbSdk({baseUrl:'http://bb.test',fetch:async()=>response});
  assert.deepEqual(await sdk.hosts.installProviderCli({hostId:'test-host',provider:'test-provider',actionKind:'update'}), events);
  console.log('PASS: native response installer events parsed');
} finally {
  globalThis.Response = originalResponse;
  globalThis.Request = originalRequest;
}

Root cause

SDK response consumption calls the global Response prototype with a transport-owned receiver. Server startup uses Hono serve with default global overrides. The installed adapter text method calls its private getResponseCache symbol, absent on native Fetch responses. Installer route returns newline-delimited data. The parsing schema is unchanged.

Proposed fix and validation

Use the returned response's own text method. Annotate the local response as Response to widen Hono's inferred text return type without a cast or contract change. The focused regression test substitutes a global Response class with private state, supplies a native transport response, and checks multiple events, CRLF and blank lines. Before: 1 failed, 104 passed. After: all 105 SDK tests pass, SDK typecheck and build pass. The real adapter reproduction also passes after rebuilding.

Verification

The same agent created a second clean detached worktree at b04091eca67bb463cce16b9bfa318660bd20ab69, installed frozen dependencies, built the SDK, and ran the identical node reproduction. It threw the exact getResponseCache exception. The regression test was then copied in and run with pnpm exec turbo run test --filter=@bb/sdk: 1 failed, 104 passed. No report correction was needed; provider binary state remains explicitly unverified.

Related issues and PRs

No open PR referencing #3466 was found during the check. Recent plugin-area issues concerned other SDK features.

Appendix

Issue data was treated as untrusted evidence; no issue-supplied code or links were executed. The reproduction was authored from trusted repository source. Logs have local paths removed.

> AGENT GENERATED