Skip to content

Unhandled Promise rejection for ParseUser save() #1386

@tboily

Description

@tboily

New Issue Checklist

Issue Description

If an error is thrown by Parse-Server on a Parse.User.save(), the SDK does not catch it and an Unhandled Promise Rejection error is raised, making it impossible for our app to catch the error.

There may be some sort of wrapper I am not aware of, but I gave a quick look to the code and to the untrained eye, it simply looks as though there is no try-catch block in the save() method of ParseUser (src/ParseUser.js). Same goes for other methods like destroy().

According to logs, error is raised at ParseObject.js:3137, but the absence of ParseUser in the error stack gives me the feeling it is indeed the culprit.

Steps to reproduce

In our case, we did as follows:
Update a user with an email already used and call save().

// user is an instance of Parse.User()
try {
    user.email = '[email protected]';
    await user.save()
} catch (err) {
    // We know there is an error but we never end up here because user's save() does not throw.
    throw err;
}

Actual Outcome

Logs show an unhandled promise rejection, and nothing is caught in our catch block.

Expected Outcome

The SDK should catch the error and throw it back to the app.

Environment

nodejs 12.16.1
parse 3.3.0
parse-server 4.5.0

We were working with earlier versions of parse and parse-server before and updated to the latest versions to see if this error was fixed.

Server

  • Parse Server version: 4.5.0
  • Operating system: Google App Engine (some version of Linux)
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): Google Cloud

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: 4.4.6
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): MongoDB Atlas

Client

  • Parse JS SDK version: 3.3.0

Logs

(node:10) UnhandledPromiseRejectionWarning: Error: Account already exists for this email address.
      at /workspace/node_modules/parse/lib/node/ParseObject.js:3137:35
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:10) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 6)
(node:10) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions