Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Promise rejection for ParseUser save() #1386

Open
4 tasks done
tboily opened this issue Jul 13, 2021 · 4 comments
Open
4 tasks done

Unhandled Promise rejection for ParseUser save() #1386

tboily opened this issue Jul 13, 2021 · 4 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@tboily
Copy link

tboily commented Jul 13, 2021

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 = 'alreadyInDb@test.com';
    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.
@mtrezza mtrezza added state:needs-investigation type:bug Impaired feature or lacking behavior that is likely assumed labels Oct 5, 2021
@dplewis
Copy link
Member

dplewis commented Apr 14, 2024

@mtrezza I can't replicate this issue. user.email = 'alreadyInDb@test.com'; not sure how this works since a setter for this doesn't exist.

@mtrezza
Copy link
Member

mtrezza commented Apr 14, 2024

If two users are saved with identical email addresses, is that the error that is mentioned?

@dplewis
Copy link
Member

dplewis commented Apr 15, 2024

Yeah but using the example posted I can't get Unhandled Promise rejection or the error.

@mtrezza
Copy link
Member

mtrezza commented Apr 15, 2024

If you just save two users with identical email addresses, do you get an Unhandled Promise rejection error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

3 participants