fix: Send a SeamHttpRequest at most once - #1002
Merged
Merged
Conversation
A SeamHttpRequest re-executed the HTTP request every time it was awaited or given a then, catch, or finally callback. Any defensive logging idiom, Promise.all with the same request, or awaiting a stored request twice silently repeated the request, duplicating writes such as door unlocks or access code creation. Memoize the promises from execute and fetchResponse so the request is sent at most once and every consumer observes the first execution. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2
This was referenced Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SDK audit finding C1 (critical, runtime-verified): a
SeamHttpRequestre-executes the HTTP request every time it is awaited or given athen,catch, orfinallycallback — nothing memoizes the in-flight promise. Since the classimplements Promise, once-only semantics are the reasonable assumption.Any defensive-logging idiom,
Promise.all([r, r]), or awaiting a stored request twice duplicates writes: two access codes created, a door unlocked twice. For action-attempt routes each re-execution also restarts a full poll loop.Fix
Memoize the promises from
execute()andfetchResponse()in private fields, so the request is sent at most once and every consumer observes the first execution (including a cached rejection). Documented the at-most-once contract in the class JSDoc and the README's Inspecting the Request section.Tests
New tests count real server hits via a request interceptor against fake-seam-connect:
await+Promise.all([r, r])→ 1 request.catch()afterawait→ 1 request.finally()→ 1 requestlocks.unlockDoor) awaited twice +.catch()→ 1 POST, sameaction_attempt_idVerified per the audit-notes recipe: with the source fix reverted, all 5 new tests fail with the audit's exact symptom (multiple deliveries); with the fix they pass. Full suite: 130 tests, lint, and typecheck green.
Part of applying the rev-3 SDK audit to this SDK (one PR per finding, mirroring seamapi/php#465–#479).
🤖 Generated with Claude Code
https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2
Generated by Claude Code