parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Unhandled Rejection when adding deviceToken to Installation

Open kahoona77 opened this issue 9 years ago • 4 comments

Issue Description

I have an an Problem with an unhandled rejection when adding a deviceToken to an Installation.

The problem is, that the code tries to delete an installation that might have this deviceToken and that is not equal to the objectID. But when there is no other installation with this deviceToken then there is nothing to delete and the promise from (this.config.database.destroy('_Installation', delQuery); in RestWrite.js ) is rejected. This leads to an unhandledRejection Error in node, which is polluding the logs.

Is there a way to avoid this? Or could this rejection be handled?

Thanks in advance!

Steps to reproduce

Add a new deviceToken to an Installation. For instance:

PUT http://.../api/classes/_Installation/b8otEVPJCw { "pushType": "gcm", "deviceToken": "fdsf-TGlr5czq5y7PFdRUcxxycmMm5kD0u1AyKxYrL2t4fmcobWFJyqXRe4KlXikr9UP2a8ijsnpkNhuPXXvZbiC4B3tQYzTfFht8sFAgkfyZkZFlUnPFVg6jaaDVJsVeGQkxZi703A", "objectId": "b8otEVPJCw" }

Expected Results

The Installation is updated and no error is logged.

Actual Outcome

The Installation is updated, but an error is logged:

You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
[object Object]

The error is actually: code=101, message=Object not found.

Environment Setup

  • Server
    • parse-server version : 2.3.8
    • Operating System: ubuntu-sever 14.04
    • Localhost or remote server: AWS

Logs/Trace

You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
[object Object]

kahoona77 avatar Apr 26 '17 14:04 kahoona77

Unhandled rejection would log only on nodejs 6.9+, we need to update the code for those. A PR is welcome :)

flovilmart avatar Apr 26 '17 14:04 flovilmart

Thanks, for the quick response. I will be looking into creating an PR in the coming days.

kahoona77 avatar Apr 27 '17 12:04 kahoona77

Awesome! Thanks!

flovilmart avatar Apr 27 '17 12:04 flovilmart

Hi, I just submitted an PR (https://github.com/parse-community/parse-server/pull/3795) for this.

kahoona77 avatar May 09 '17 07:05 kahoona77