Skip to content

Epic: 4.0 refactor #102

Description

@gmoon

Epic: 4.0 refactor

Goal

Eliminate the silent error contract, decompose the god class, replace the internal AWS SDK middleware hack, and prepare the library to host extension packages (compress, cache, signed-URL fallback) — all while keeping the test suite green at every commit.

Why now

  • v3 error contract is broken in practice: 404s call res.writeHead() from inside the proxy and substitute an empty stream, so consumer error handlers either get headers-already-sent errors or never fire.
  • The AWS SDK middleware-stack hack uses undocumented internals with a load-bearing "not sure why" comment. One SDK upgrade away from breaking.
  • The current proxy.get(req, res) shape (writes res and returns the stream) blocks any clean extension model — compression, caching, signed-URL fallback all need an unwritten response to operate on.

Phase A — independent (no API changes; can ship incrementally)

Phase B — breaking refactor (4.0)

Dependencies

Out of scope (4.1+)

  • @s3proxy/compress — gzip/brotli with Accept-Encoding negotiation, ETag invalidation, Range interaction
  • @s3proxy/cache — disk/Redis with ETag-aware revalidation, Range support
  • @s3proxy/signed-url-fallback — 302 to presigned URL above a size threshold (egress lever)
  • Multi-bucket routing
  • OpenTelemetry adapter

Migration

A MIGRATION.md ships in this PR with sed-able before/after for the Express handler, init() removal, and typed error catches.

Discipline

This work is being executed under a one-shot prompt with non-negotiable rules:

  1. Every commit leaves the working tree green (unit + integration + lint + type-check + examples smoke).
  2. Every commit changing production code includes the matching test update in the same commit.
  3. No it.skip, no it.only, no commented-out tests.
  4. The simplify skill runs at the end of every issue.

Decision log

<append-only — date, decision, reason>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    epicTracking issue for a multi-issue effortv4Targeted for the 4.0 release

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions