feat: getOrgFullScanCached with 202 polling for cached full scans#660
Closed
John-David Dalton (jdalton) wants to merge 1 commit into
Closed
Conversation
getOrgFullScanCached reads a full scan's artifacts into memory, serving pre-computed results from the immutable scan store via ?cached=true (the default). A cache hit returns 200 with the ndjson artifacts; a cache miss returns 202 Accepted while the server computes them, so the method polls with exponential backoff until a 200 arrives or the poll budget is spent. Unlike the streaming getOrgFullScan it buffers and returns the parsed artifacts instead of piping to a stream, so it never pipes a non-existent stream on a 202. The streaming getOrgFullScan is left untouched.
Collaborator
Author
|
Withdrawing: strategy changed — socket-cli v1.x will move to the latest @socketsecurity/sdk (4.x) and the SDK v1.4.x/v1.x release branches won't be maintained. SURF-742 for the shipping line is being done as a direct-API backport in socket-cli v1.x (no SDK dependency), so this v1.4.x SDK change isn't needed. The equivalent already exists on socket-sdk-js main. |
John-David Dalton (jdalton)
deleted the
jdalton/surf-742-add-support-for-the-cached-flag-in-the-sdkcli-for-full-scans
branch
July 24, 2026 12:48
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.
Adds a buffered, cache-aware full-scan reader for the v1.4.x SDK line. Linear: SURF-742.
getOrgFullScanCached(orgSlug, fullScanId, options?)?cached=trueby default (immutable scan store).{ success, status: 200, data: SocketArtifact[] }.{ success: false, status: 202, error: 'Cached full scan not ready', ... }.cached: false→ sends no cached param and returns the first 200 with no polling.The streaming
getOrgFullScanis untouched — it still pipes to a file/stdout, so it never has to "pipe a non-existent stream" on a 202. Buffered vs streamed are separate methods on purpose: wideninggetOrgFullScan's return type breakshandleApiCall<T>inference at the CLI's--streamcall site, which SURF-742 requires to stay untouched.Consumed by SocketDev/socket-cli#1425 (base
v1.x), which pins the next SDK release (1.4.97) forsocket scan view.Verification
tsc --noEmit: cleaneslint+oxlint+biome: clean (sequentialawaits in the poll loop carry the repo'seslint-disable no-await-in-loop, matching existing callsites)vitest: 14/14 pass, incl. 5 new nock-driven cases intest/full-scan-cached.test.ts(200 hit, 202→200 poll, timeout,cached:false, 404)