Skip to content

Issue with node 25, firebase-admin@13.5.0 #2996

@sethsnel

Description

@sethsnel

My environment

  • Operating System version: Windows 11 Pro
  • Firebase SDK version: 13.5.0
  • Firebase Product: auth
  • Node.js version: 24.10.0 upgrade to 25.0.0
  • PNPM version: 10.19.0

The problem/symptom

After upgrading to node 25.0.0, I started seeing this error message in my build output:

[Error: Failed to collect page data for /api/admin/users] {
  type: 'Error'
}
 ELIFECYCLE  Command failed with exit code 1.

When I remove all imports from import { auth } from "firebase-admin", then my build succeeds.
My assumption is that there is something in firebase-admin and or auth that is incompatible with node 25.
Perhaps it's just how I use it, I'm willing to provide more information about my app.

Steps to reproduce:

For me it's reproducible by using node 25.0.0 and using modules from firebase-admin.

Example usage:

Client initialization

import admin from 'firebase-admin'

const firebaseAdmin = admin.initializeApp({
  credential: admin.credential.cert({
    projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
    privateKey: process.env.FIREBASE_PRIVATE_KEY?.replace(/\\n/g, '\n'),
    clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
  }),
})

export default firebaseAdmin

Example usage: Api middle ware for token verification

import { auth } from "firebase-admin"
import { headers } from 'next/headers'

import { firebaseAdmin } from "."

export default async function validateAdminRequest(): Promise<number> {
  const headersList = await headers()
  const idToken = headersList.get('vs-auth-token')

  if (idToken === undefined || !idToken || typeof idToken === 'undefined') {
    return 401
  }

  try {
    const decodedToken = await auth(firebaseAdmin).verifyIdToken(idToken as string)

    if (!decodedToken.admin) {
      return 403
    }
  }
  catch (error: any) {
    if (error.codePrefix === 'auth') {
      return 401
    }
    else {
      return 500
    }
  }

  return 200
}

Example usage: Api/Users endpoint

import { ListUsersResult } from 'firebase-admin/lib/auth/base-auth'

import { firebaseAdmin } from '../../../../lib/server'
import { validateAdminRequest } from '../../../../lib/server'
import { NextRequest, NextResponse } from 'next/server'

export async function GET(
  req: NextRequest
) {
  var requestResponseCode = await validateAdminRequest()
  if (requestResponseCode !== 200) {
    return NextResponse.json([], { status: requestResponseCode })
  }

  const listAllUsers = async (depth: number = 0, nextPageToken?: string): Promise<ListUsersResult> => {
    const listUsersResult = await auth(firebaseAdmin).listUsers(20, nextPageToken)

    if (listUsersResult.pageToken && depth > 0) {
      return listAllUsers(--depth, listUsersResult.pageToken)
    }

    return listUsersResult
  }

  var fetchedUsers = await listAllUsers()
  return NextResponse.json(fetchedUsers.users)
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions