Skip to content

Admin SDK uses Math.random during initialization, making it unsuitable to use in a RSC #3075

@jamesdaniels

Description

@jamesdaniels

[READ] Step 1: Are you in the right place?

  • For issues related to the code in this repository file a Github issue.
  • If the issue pertains to Cloud Firestore, read the instructions in the "Firestore issue"
    template.
  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general Firebase discussion, use the firebase-talk
    google group.
  • For help troubleshooting your application that does not fall under one
    of the above categories, reach out to the personalized
    Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Operating System version: _____
  • Firebase SDK version: _____
  • Firebase Product: _____ (auth, database, storage, etc)
  • Node.js version: _____
  • NPM version: _____

[REQUIRED] Step 3: Describe the problem

The Firebase Admin SDK uses Math.random on itialization, which is a "personalized" API and not permitted during SSG.

Error: Route "***" used `Math.random()` before accessing either uncached data (e.g. `fetch()`) or Request data (e.g. `cookies()`, `headers()`, `connection()`, and `searchParams`). Accessing random values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-random

Steps to reproduce:

Use the admin sdk in a NextJS application with RSC, SSG, and PPR.

Relevant Code:

initializeApp(...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions