fix: S3Client singleton and R2 error logging

🟢 open · #108 · willchen96/mike ← bmersereau/mike · opened 13d ago by bmersereau · +1,339-19 across 7 files · ↗ on GitHub

From the PR description

Summary

  • Hoists S3Client to a module-level singleton (lazy-initialised on first use) - prevents a new client being allocated on every R2 operation and enables HTTP keep-alive connection reuse
  • Adds console.error logging to the catch blocks in downloadFile and getSignedUrl so R2 outages appear in server logs rather than silently returning null
  • Removes stray editResolutionLogging.test.ts that was copied from an unrelated branch and caused test failures on this branch

Closes #101 Closes #102 Closes #115 Closes #116 Closes #125

Changes

  • backend/src/lib/storage.ts - singleton _client + error logging in catch blocks
  • backend/src/lib/__tests__/storage.test.ts - basic storage module tests
  • backend/vitest.config.ts - isolate: true added for consistent module isolation
  • backend/package.json - "test": "vitest run" script added

Test plan

  • Unit tests added and passing (3/3)
  • Backend build passes

Our analysis

Hoist R2 S3Client to a module-level singleton — read the full analysis →

Think the analysis missed something the PR description covers?

Capture this PR into my fork

Download a Markdown prompt that tells Claude how to port every commit in this PR into your working tree. Run it via claude -p < capture-pull-108.md from inside the repo you want the changes in.

⬇ Download capture-pull-108.md