parse-community / parse-server

Parse Server for Node.js / Express
https://parseplatform.org
Apache License 2.0
20.81k stars 4.77k forks source link

Migration Guide to Parse Server 6 issues #8383

Open mman opened 1 year ago

mman commented 1 year ago

New Issue Checklist

Issue 1 Description

I am following the migration guide to Parse Server 6, and encountered couple of issues.

I have changed my code to use simpler initialisation:

https://github.com/parse-community/parse-server/blob/76c7a6fbd06693229c1906d68117713bc0a18d42/6.0.0.md?plain=1#L28

And I get the following error:

const api = new ParseServer({...});
            ^

TypeError: ParseServer is not a constructor

I still have to use the old method of const ParseServer = require('parse-server').ParseServer; to get the proper constructor.

Issue 2 Description

Trying to start the parse server in async way via:

await api.start();

Produces the following error:

  await api.start();
  ^^^^^

SyntaxError: await is only valid in async functions and the top level bodies of modules

I have to use the following workaround to actually produce async context on top level of my index.js:

(async function main () {
  await api.start();
})();

Server

parse-github-assistant[bot] commented 1 year ago

Thanks for opening this issue!

mtrezza commented 1 year ago

SyntaxError: await is only valid in async functions and the top level bodies of modules

Which Node version are you running? await on top level is unflagged since Node 14.8.0.

cbaker6 commented 1 year ago

SyntaxError: await is only valid in async functions and the top level bodies of modules

@mman I followed the migration guide and the directions worked for me. Your error seems to be related to how you are calling your async method. My updated code is here for reference: https://github.com/netreconlab/parse-hipaa/blob/89ccb02db7970ffd494a1dae907f9a660e117171/parse/index.js#L407-L409. I used the 6.0.0-alpha.21 image for testing my development servers, but it worked on 6.0.0-alpha.17 also.

As far as your first issue, I still used the old way as well...

mtrezza commented 1 year ago

@dblythy Could you take a look at @mman's issue 1?

mman commented 1 year ago

@cbaker6 Looks like you are calling async function from top-level without await, and in your async function then await parse.start(). I am calling await parse.start() on the top level and that fails. Node 16.

mman commented 1 year ago

SyntaxError: await is only valid in async functions and the top level bodies of modules

Which Node version are you running? await on top level is unflagged since Node 14.8.0.

@mtrezza This is happening for me on Node 16.