Skip to content

beforeSave() hook causes "Object Not Found" error #6195

Closed
@drhuanliu

Description

@drhuanliu

Issue Description

I just upgrade from Parse Server 2.7 to 3.9, and this new issue starts to happen:

  • We save a bunch of PFObjects from iOS in bulk with PFObject.saveAll(inBackground: array.....
  • In ParseServer, we have a beforeSave, and afterSave hook to do extra steps
  • When saving more than one object, the server would return "Object Not Found" error

I trace the error to line 209 of RestWrite.js. Apparently, this call

databasePromise = this.config.database.create(this.className, this.data, this.runOptions, true);

does not return back an object, resulting in throwing an exception.

Here is what I know:

  • Problem does not happen in 2.7
  • Problem does not happen if just save one object
  • Problem does not happen if I do not declare the beforeSave function
  • Problem does happen if I declare the beforeSave function, even if the function is empty (doing nothing)

Could you please take a look at that section of the RestWrite.js code, and see what could potentially be causing it to raise an exception?

Steps to reproduce

  • Write a cloud code function with beforeSave for a class X
  • Save an array of class X objects from iOS clients

Expected Results

  • I expect all saves to be successful

Actual Outcome

  • Get "object not found" exception

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 3.9
    • Operating System: Windows
    • Hardware: Azure cloud
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Azure
  • Database

    • MongoDB version: 3.2.1 Community
    • Storage engine: not sure
    • Hardware: Azure
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): Azure

Logs/Trace

Include all relevant logs. You can turn on additional logging by configuring VERBOSE=1 in your environment.

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