Open
Conversation
…-queue Remove duplicated PromiseQueue implementation and import from the shared library instead. The lib version has an identical API with a more efficient idle notification mechanism.
Replace raw node:http/node:https usage with lib's httpRequest() in
http-client.ts and socket-sdk-class.ts. This deduplicates HTTP handling
logic and aligns the SDK with the shared library's request infrastructure.
Key changes:
- createGetRequest, createDeleteRequest, createRequestWithJson now use
httpRequest() and return HttpResponse instead of IncomingMessage
- ResponseError.response is now HttpResponse (status/statusText vs
statusCode/statusMessage)
- isResponseOk uses response.ok instead of manual statusCode range check
- getErrorResponseBody/getResponseJson work with buffered HttpResponse
- NDJSON streaming replaced with response.text().split('\n') parsing
- downloadOrgFullScanFilesAsTar and streamFullScan use buffered writes
- downloadPatch simplified from raw http.get to httpRequest()
- file-upload.ts wraps IncomingMessage via wrapIncomingMessage() adapter
- getHttpModule and getResponse retained for file-upload.ts compatibility
The retry logic was retrying all HTTP errors including 4xx client errors (400, 404, etc.) which are permanent failures that won't succeed on retry. After migrating to @socketsecurity/lib/http-request, this caused ERR_NOCK_NO_MATCH in tests because nock interceptors were consumed on the first attempt but pRetry would retry. Changes: - Throw immediately on 4xx errors (except 429) in #executeWithRetry to prevent wasteful retries of permanent failures - Always retry 429 (rate limiting) with default backoff when Retry-After header is missing/invalid/past, since rate limits are temporary - Use nock callback-style replies for 400/404 tests (nock v14 with @mswjs/interceptors requires this for httpRequest compatibility) - Update stream-limits test to expect thrown error since lib enforces maxResponseSize at network level (non-ResponseError)
divmain
approved these changes
Apr 5, 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.
Summary
src/promise-queue.tsand importPromiseQueuefrom@socketsecurity/lib/promise-queuesrc/http-client.tsto use@socketsecurity/lib/http-requestinternally (-472 net lines)createGetRequest,createDeleteRequest,createRequestWithJsonnow use lib'shttpRequest()ResponseError.responsechanged fromIncomingMessagetoHttpResponseisResponseOkusesresponse.ok,getErrorResponseBodyusesresponse.text()node:http/node:httpsusage from request functionsgetHttpModule/getResponseretained forfile-upload.tsbackward compatsocket-sdk-class.ts:IncomingMessage→HttpResponse,.statusCode→.status, streaming → buffered readsTest plan