Skip to content

Invalid date iso with beforeSave make server unhandled promise rejection and request hanging  #7192

Open
@sunshineo

Description

@sunshineo

Issue Description

Have a class with a column type Date. Try post with empty string as iso. Get proper error back

{
    "code": 111,
    "error": "This is not a valid Date"
}

Add beforeSave to the class and post again. Request will hang there forever. Server will fail with the following errors

(node:63110) UnhandledPromiseRejectionWarning: Error: Tried to encode an invalid date.
    at encode (/Users/gordon/workspace/pipe17/pipe17-group/parse/node_modules/parse/lib/node/encode.js:85:13)
    at _default (/Users/gordon/workspace/pipe17/pipe17-group/parse/node_modules/parse/lib/node/encode.js:132:10)
    at SetOp.toJSON (/Users/gordon/workspace/pipe17/pipe17-group/parse/node_modules/parse/lib/node/ParseOp.js:155:32)
    at ParseObject._getSaveJSON (/Users/gordon/workspace/pipe17/pipe17-group/parse/node_modules/parse/lib/node/ParseObject.js:485:61)
    at success (/Users/gordon/workspace/pipe17/pipe17-group/parse/node_modules/parse-server/lib/triggers.js:385:45)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
  • 🤩 I will submit a PR with a fix (but probably need someone else do a proper fix)

Environment

Server

  • Parse Server version: 4.5.0

Metadata

Metadata

Assignees

No one assigned

    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