Skip to content

TypeError: Cannot read property 'INTERNAL' of undefined at FirebaseNamespace.initializeApp #593

@liamdanielduffy

Description

@liamdanielduffy

[REQUIRED] Step 2: Describe your environment

  • Operating System version: macOS 10.14.4 (18E226)
  • Firebase SDK version: 8.2.0
  • Library version: unclear what this means
  • Firebase Product: initialization of admin app

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

Clone the following repository:
https://github.com/liamdanielduffy/firebase-admin-bug-repro

Run npm install or yarn in the repository root.
Run npm run dev or yarn dev to start the server.
Visit localhost:3000/api/graphql.

See the following message printed in the server logs:

TypeError: Cannot read property 'INTERNAL' of undefined
    at FirebaseNamespace.initializeApp (.../firebase-admin-bug-repro/node_modules/firebase-admin/lib/firebase-namespace.js:392:21)
    ...(rest of stack trace)

Further context

The firebase admin SDK is being initialized in libraries/firebase/initializeAdminApp.
The service account key is present in the repository, and is exported from libraries/firebase/getKey.

On each network request to localhost:3000/api/graphql, the function defined in libraries/apollo/getContext is called. This function attempts to pass the firebase app as part of the 'context' for all the graphql resolvers defined in libraries/nexus/schema.

I'm not sure why the error is being printed above, but the stack trace above points to this line in the firebase-admin package: firebase-admin/lib/firebase-namespace.js:392

 FirebaseNamespace.prototype.initializeApp = function (options, appName) {
        return this.INTERNAL.initializeApp(options, appName);
    };

this is undefined, creating the error thrown.

Why would that happen? Am I initializing this in the wrong way or in the wrong place?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions