Skip to content

perf(r2): reuse validated S3 client - #96

Open
vsolano9 wants to merge 1 commit into
AgentPostmortem:mainfrom
vsolano9:fix-45-r2-client-config
Open

perf(r2): reuse validated S3 client#96
vsolano9 wants to merge 1 commit into
AgentPostmortem:mainfrom
vsolano9:fix-45-r2-client-config

Conversation

@vsolano9

Copy link
Copy Markdown

Closes #45

What changed

  • lazily create and memoize one Cloudflare R2 S3Client for upload and read presigns
  • validate all four required R2 variables before client construction and name the missing variable in the error
  • reuse the validated bucket name instead of repeated non-null assertions
  • cover client reuse and every required-variable failure without contacting R2

Validation

  • Node 22.23.2: npx vitest run — 14 files, 126 tests passed
  • Node 22.23.2: npx tsc --noEmit
  • Node 22.23.2: npm run lint — no warnings or errors
  • Node 22.23.2: npx prettier --check .
  • Node 22.23.2: npm run build with the CI placeholder environment
  • focused R2 test file repeated 20 times

No dependency or lockfile changes.

Memoize the lazily constructed Cloudflare R2 client and fail with a readable, variable-specific error before signing when required configuration is absent. Add coverage for reuse across upload/read presigns and every required variable.

Closes AgentPostmortem#45
@github-actions

Copy link
Copy Markdown

Welcome, @vsolano9, and thanks for your first pull request to agentpostmortem.

A quick look at CONTRIBUTING.md covers how things are set up and run here.

I'll review this shortly. Ask anything in the thread if something is unclear.

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.

Memoize the R2 S3Client and validate its environment variables with readable errors

1 participant