Skip to content

Modernize functions/ to Firebase v2 SDK, Node ≥22; remove node-fetch from root lib#60

Merged
ernysans merged 6 commits into
mainfrom
copilot/epic-cleanup-firebase-functions
Jul 15, 2026
Merged

Modernize functions/ to Firebase v2 SDK, Node ≥22; remove node-fetch from root lib#60
ernysans merged 6 commits into
mainfrom
copilot/epic-cleanup-firebase-functions

Conversation

Copilot AI commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

The functions/ sub-project was pinned to an EOL stack (Node 16, firebase-admin@^11, firebase-functions@^4, ESLint 8 + eslint-config-google) while the root library had already moved to v2/Node 22. It also relied on a Gen-1 Auth trigger with no direct Gen-2 equivalent, and the root library depended on node-fetch with a timeout option that is silently ignored on node-fetch@3.

Auth trigger migration

  • Replaced the Gen-1 functions.runWith().auth.user().onCreate() trigger with the Gen-2 blocking function beforeUserCreated (firebase-functions/v2/identity), dropping the @ts-ignore in favor of an explicit typed cast:
export const created = beforeUserCreated({
  memory: '512MiB',
  timeoutSeconds: 60,
}, async (event) => {
  const user = event.data;
  if (!user) return;
  await User.Helper.onCreate(user as unknown as UserRecord, mainUrl);
});
  • Replaced remaining @ts-ignore in actions.ts with typed catch (error: any) narrowing.

functions/ dependency & tooling upgrade

  • engines.node>=22, firebase-admin^13, firebase-functions^7, typescript^6.
  • Removed unused cors, @google-cloud/functions-framework, firebase-functions-test.
  • Replaced legacy .eslintrc.json/.eslintignore with a flat eslint.config.js mirroring the root config; dropped the unmaintained eslint-config-google/ESLint 8 toolchain.
  • Fixed tsconfig.json's module/moduleResolution mismatch and removed unused experimentalDecorators, emitDecoratorMetadata, downlevelIteration, and other deprecated compiler options.
  • Fixing the tsconfig let the project compile for the first time in a while, which surfaced a real bug in media/open.ts: a required request field was missing from the Media.Helper.preview call — now passed through.

Root library: drop node-fetch

  • src/api-request.ts and src/media.ts now use native fetch (Node ≥22) instead of node-fetch, replacing the ignored timeout option with AbortSignal.timeout(60000) and dropping node-fetch-only options (follow, size, agent, compress).
  • Removed the node-fetch dependency and updated tests to mock the global fetch.
  • Removed unused experimentalDecorators/emitDecoratorMetadata from the root tsconfig.json.

Docs

  • Updated README.MD / functions/README.MD to reflect the new Node/SDK versions and the v1→v2 trigger change.

Out of scope

  • Repo-wide strictNullChecks/noImplicitAny re-enablement was not attempted — it surfaces ~30 unrelated null-safety diagnostics across user.ts, media.ts, global.ts, etc., and warrants a dedicated follow-up.
  • express stays at ^4 in functions/; bumping to ^5 changes wildcard route matching (/media/**) and needs its own review. @types/express was aligned to ^5 (dev-only) to match the compiled root library types.

Copilot AI linked an issue Jul 15, 2026 that may be closed by this pull request
33 tasks
Copilot AI changed the title [WIP] Update Firebase Functions to use v2 SDK and modern dependencies Modernize functions/ to Firebase v2 SDK, Node ≥22; remove node-fetch from root lib Jul 15, 2026
Copilot AI requested a review from ernysans July 15, 2026 14:46
@ernysans
ernysans force-pushed the copilot/epic-cleanup-firebase-functions branch from 57b2485 to 6187c5f Compare July 15, 2026 15:14
@ernysans
ernysans marked this pull request as ready for review July 15, 2026 15:14
@ernysans
ernysans merged commit 0483ba7 into main Jul 15, 2026
2 checks passed
@ernysans
ernysans deleted the copilot/epic-cleanup-firebase-functions branch July 15, 2026 15:14
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.

Epic: Firebase Functions Deprecation Clean-up — Modernize SDK & Node Dependencies

2 participants