Skip to content

Firebase Admin 12.1.1 issue with error.ts #2571

Closed
@Nushio

Description

@Nushio

[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: MacOSX
  • Firebase SDK version: 12.2.1
  • Firebase Product: logger
  • Node.js version: 18.18.2
  • NPM version: 9.8.1

[REQUIRED] Step 3: Describe the problem

Upgraded a (mature) codebase from 12.1.0 to 12.1.1, unit tests will no longer pass.

TypeError: Cannot read properties of undefined (reading 'message')

Narrowed down the issue to src/utils/error.ts line 62

If I add an optional to errorInfo?.message, and the tests pass now.

This file hasn't changed in over 3 years according to the github history, so the fact that it's failing now might be related to something introduced in 12.1.1, probably #2151

Steps to reproduce:

Upgrade to 12.1.1, and write a simple test using jest.

Note I am using pnpm, but the error also occurs if you use npm:

at FirebaseError.get message [as message] (../node_modules/.pnpm/firebase-admin@12.1.1/node_modules/firebase-admin/lib/utils/error.js:46:31)
at Array.forEach ()
at Array.forEach ()
at Array.forEach ()
at Object. (../node_modules/.pnpm/firebase-functions@5.0.1_firebase-admin@12.1.1/node_modules/firebase-functions/lib/common/providers/firestore.js:25:19)
at Object. (../node_modules/.pnpm/firebase-functions@5.0.1_firebase-admin@12.1.1/node_modules/firebase-functions/lib/v2/providers/firestore.js:32:21)
at Object. (../node_modules/.pnpm/firebase-functions@5.0.1_firebase-admin@12.1.1/node_modules/firebase-functions/lib/v2/index.js:56:19)

Relevant Code:

/** @returns The error message. */
public get message(): string {
return this.errorInfo.message;
}

// TODO(you): code here to reproduce the problem

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions