Skip to content

refactor!: v4 breaking changes, perf improvements, and cleanup#564

Merged
John-David Dalton (jdalton) merged 1 commit intomainfrom
refactor/v4-breaking-changes
Apr 7, 2026
Merged

refactor!: v4 breaking changes, perf improvements, and cleanup#564
John-David Dalton (jdalton) merged 1 commit intomainfrom
refactor/v4-breaking-changes

Conversation

@jdalton
Copy link
Copy Markdown
Contributor

Summary

All v4 breaking changes, performance optimizations, and cleanup — without version bump or changelog, to allow independent review.

Breaking Changes

  • HTTP client refactored: All methods return HttpResponse from @socketsecurity/lib/http-request instead of IncomingMessage
  • Unified HTTP transport: File uploads migrated from node:http/getResponse() to httpRequest()
  • Trimmed public API: Removed 20+ internal helpers, utilities, and constants from main entry point
  • Removed: getHttpModule, getResponse, getErrorResponseBody, createRequestBodyForJson, getSupportedScanFiles(), PromiseQueue
  • Removed deps: @socketregistry/packageurl-js (unused), http2-wrapper (replaced by native node:http2)

Performance

  • Cached reqOptionsWithHooks — eliminates 60+ object spreads per session
  • NDJSON: .split('\n') → single-pass linear scan (4 locations)
  • queryToSearchParams: avoid double URLSearchParams instantiation
  • sanitizeHeaders: deferred behind if guards (9 locations)
  • batchPackageStream: findIndex+spliceMap for O(1) operations
  • reshapeArtifactForPublicPolicy: Set-based allowedActions, single-pass reduce

Bug Fixes

  • Fix streamFullScan using MAX_STREAM_SIZE (100MB) for buffered responses — now uses MAX_RESPONSE_SIZE (10MB)
  • Add missing maxResponseSize to createUploadRequest

Stats

  • +465 / -1,005 lines across 18 files
  • 20 test files, 565 tests passing
  • 96.95% code coverage, 100% function coverage

Test plan

  • pnpm build passes
  • pnpm test — 565 tests pass
  • Pre-commit hooks pass (lint, type check, full test suite)
  • Reviewed by Claude, Codex, and 3 exploration agents

Breaking changes:
- HTTP client returns HttpResponse instead of IncomingMessage
- Unified file-upload onto httpRequest() transport
- Removed getHttpModule, getResponse, getErrorResponseBody,
  createRequestBodyForJson, getSupportedScanFiles, PromiseQueue
- Trimmed public API surface — removed internal helpers from exports
- Replaced http2-wrapper type with native node:http2
- Removed @socketregistry/packageurl-js and http2-wrapper deps

Performance:
- Cached reqOptionsWithHooks — eliminates 60+ object spreads per session
- NDJSON linear scan replaces .split('\n') in 4 locations
- queryToSearchParams avoids double URLSearchParams instantiation
- sanitizeHeaders deferred behind if guards (9 locations)
- batchPackageStream generator queue uses Map for O(1) operations
- reshapeArtifactForPublicPolicy: Set-based allowedActions, single-pass reduce

Bug fixes:
- Fix streamFullScan using MAX_STREAM_SIZE (100MB) for buffered responses
- Add missing maxResponseSize to createUploadRequest
Comment thread src/file-upload.ts
@jdalton John-David Dalton (jdalton) merged commit c8ba283 into main Apr 7, 2026
10 checks passed
@jdalton John-David Dalton (jdalton) deleted the refactor/v4-breaking-changes branch April 7, 2026 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants