parse-server: Cloud Code import can cause race condition

New Issue Checklist

Issue Description

Module import is async, importing as module can currently cause a race issue. A developer do not have any guarantee that the code will be loaded before he try to run some cloud code functions. We have some recurrent CI fails due to https://github.com/parse-community/parse-server/pull/7560.

See https://github.com/parse-community/parse-server/pull/7560#issuecomment-962053007

Steps to reproduce

Actual Outcome

Random CI fails

Expected Outcome

No flacky

Environment

beta

Server

  • Parse Server version: 5.0.0-beta.1
  • Operating system: all
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): action

Database

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

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): beta
  • SDK version: beta

Logs

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (15 by maintainers)

Most upvoted comments

@mtrezza @dblythy here i’m sad to announce that ParseServer is currently not ready to support an async cloud code loading correctly without being sure not to break anything on certain productions.

We need an additional PR with a clean refactoring of ParseServer startup. But changing parse server startup from sync to async will lead to a breaking change.

Since we are at beta stage, @mtrezza I think it is wiser to remove the code and open a new issue tracking the refactor needs and how this breaking could be handled without creating any surprise on some production applications.

Here i’ll suggest to remove the import code that allow cloud code file as ES Module. 🙁

I’ll have a look at #7525 today. Lmk what’s missing to be merged.

Thanks @Moumouls. Just in case we want to remove the feature, we don’t do pure git reverts, we require a new PR that removes the code. I suggest let’s see what @dblythy suggests. I renamed the title because the issue it not purely a CI issue but has potential impact on cloud code loading as I understand it.