Skip to content

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1) #266

@jbeckton

Description

@jbeckton

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

[REQUIRED] Step 2: Describe your environment

  • Operating System version: macOS 10.13.4
  • Firebase SDK version: 5.12.0
  • Library version: 5.12.0
  • Firebase Product: admin.firestore

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

What happened? How can we make the problem occur?

passing an object instance to admin.firebase().collection().doc().set();
I know this is invalid, i am trying to test error handling

This could be a description, log/console output, etc.

(node:4861) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Argument "data" is not a valid Document. Input is not a plain JavaScript object.

Relevant Code:

const newDoc = new UserDocument( { email: req.body.email, firstName: req.body.firstName, lastName: req.body.lastName } );

            admin.firestore().collection( 'users' ).doc( userRecord.uid ).set( newDoc )
                .then( () => {
                    // success
                },
                    ( err ) => {
                      //  failed
                    } )
                .catch( ( err ) => {
                    // failed
                } );

I am not aware of any other ways to handle promise rejections and errors than the above code. i am trying to test my error handling code so I broke the code on purpose but my error handling never executes because node thinks the promise rejection is not handled.

Metadata

Metadata

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