Repository navigation
chore(deps): migrate firebase-admin to v14 (#223) - #224
Conversation
- firebase-admin ^13.10.0 -> ^14.5.0 (app and functions). - Split src/lib/firebase-admin.ts into firebase-admin-app/-auth/-db/ -storage so each service graph loads only where imported — Firestore- and Storage-only routes no longer pull firebase-admin/auth, whose jwks-rsa -> jose chain caused the #144 Vercel ERR_REQUIRE_ESM outage. - Scoped override jwks-rsa -> jose@5.10.0: firebase-admin 14 resolves jwks-rsa@4 -> jose@6 (ESM-only), and Vercel's serverless loader has no require(esm) bridge — verified failing in a live Preview on deepdivebrewing-web PR #142. tests/firebase-admin-runtime.test.ts (CJS-only subprocess) now also covers firebase-admin/storage. - next.config.ts: serverExternalPackages keeps firebase-admin out of the server bundle. - functions/index.js: the legacy require("firebase-admin") namespace call migrated to firebase-admin/app (v14 removed admin.* services; only initializeApp was used). - scripts/check-admin-import.mjs wired into npm test: credential-free plain-Node import of every Admin entrypoint the app uses. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reviewer's GuideMigrates both app and Functions usage to firebase-admin 14.5.0, isolates service imports to avoid pulling Auth’s problematic jwks-rsa/jose graph into unrelated server paths, and adds dependency/runtime safeguards for CJS-compatible Vercel execution. Review the deployment validation items separately, especially invalid-token session handling, Admin/Storage rendering, and Functions execution. Sequence diagram for the Firebase Admin runtime import safeguardsequenceDiagram
participant Test as npm test
participant Check as check-admin-import.mjs
participant Node as Plain Node runtime
participant Admin as firebase-admin 14.x entrypoints
Test->>Check: node scripts/check-admin-import.mjs
Check->>Node: import firebase-admin/app
Check->>Node: import firebase-admin/auth
Check->>Node: import firebase-admin/firestore
Check->>Node: import firebase-admin/storage
Node->>Admin: resolve CJS-compatible dependency chain
Admin-->>Check: required exports available
Check-->>Test: server import chain OK
Sequence diagram for Functions Firebase initialization with Admin SDK v14sequenceDiagram
participant Functions as Functions runtime
participant App as firebase-admin/app
participant Firebase as Firebase services
Functions->>App: initializeApp()
App->>Firebase: initialize default app
Firebase-->>Functions: initialized app
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Vercel Preview runtime validation — PASSEDInitial Vercel deploy failed with Deployment: Exercised:
Runtime logs: zero error/fatal entries for the deployment window; no Firestore/Storage graphs: unchanged semantics, statically covered by Also re-ran the push-triggered E2E job that flaked on Postgres |
Picks up the E2E harness fixes (#228 registration-lifecycle root cause, #230 DB-before-app startup + per-attempt reset, #232 merge-confirmation flake) so CI runs against a stable suite. Conflict in package.json scripts resolved by union: main's storage-emulator + maintenance E2E scripts plus this branch's check:admin-import guard. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Main's vet-documents and animal-merge routes postdate the firebase-admin module split, so they still imported the removed '@/lib/firebase-admin' barrel. Point them at firebase-admin-storage, which owns adminBucket. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Closes #223
Summary
firebase-admin^13.10.0->^14.5.0(app +functions/).src/lib/firebase-admin.tsintofirebase-admin-app/-auth/-db/-storage: Firestore- and Storage-only consumers no longer importfirebase-admin/auth(the jwks-rsa -> jose graph behind the Fix production /admin crash from firebase-admin v14 ESM dependency conflict #144 Vercel outage). All call sites andvi.mockspecifiers updated.next.config.ts: addsserverExternalPackages: ["firebase-admin"].jwks-rsa -> jose@5.10.0— required, verified on a live Vercel Preview in chore(deps): migrate firebase-admin to v14 (#141) deepdivebrewing-web#142: unoverridden Admin 14.5.0 resolves jose@6.1.3 (ESM-only) and the deployed function 500s withERR_REQUIRE_ESMdespite Node 24.functions/index.js: replaces legacyrequire("firebase-admin")+admin.initializeApp()withfirebase-admin/app(v14 removed the namespaced service API; onlyinitializeAppwas used here).scripts/check-admin-import.mjswired intonpm test— credential-free plain-Node import of app/auth/firestore/storage entrypoints, asserts 14.x.tests/firebase-admin-runtime.test.ts(Fix production /admin crash from firebase-admin v14 ESM dependency conflict #144 CJS-only subprocess guard) now also loadsfirebase-admin/storage.Verification (local)
npm ci-equivalent install clean; tree:firebase-admin@14.5.0->jwks-rsa@4.1.0->jose@5.10.0(overridden)node scripts/check-admin-import.mjs->firebase-admin@14.5.0: server import chain OKnpm run type-check,npm run lintclean (5 pre-existing warnings)npm test— 869 pass incl. CJS-only runtime guardnpm run buildgreenfunctions/:npm install->firebase-admin@14.5.0+firebase-functions@7.4.0(peer-compatible)Vercel Preview validation (required before merge)
POST /api/auth/sessionwith an invalididTokenexecutesverifyIdTokenand returns the app's own 401 — not a module-graph 500/adminpage render + receipt sweep/admin path loads Storage graph; runtime logs free ofERR_REQUIRE_ESM/joseonFirestoreChange+triggerRebuildGenerated with Devin
Summary by Sourcery
Migrate Firebase Admin to v14 while hardening server-runtime compatibility across Next.js and Cloud Functions.
Bug Fixes:
Enhancements:
Tests:
Chores: