Error with mongodb when using Atlassian Connect Express 8.1.1+

I’ve been looking at updating Atlassian Connect Express (ACE) to the very latest version.

My app uses ACE with postgres (in dev, …, and production).

:white_check_mark: Using ACE v8.0.2 it works

:x: Using ACE v8.1.0 it does not work

:x: Using ACE v8.2.0 it does not work

It does not start. Here’s the console messages (which are the same for both v8.1.0 & v8.2.0):

npm run watch-server                                        

> my-app@1.0.0-AC watch-server
> NODE_ENV=development nodemon -r dotenv/config -r esm app.js

[nodemon] 2.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node -r dotenv/config -r esm app.js`

...

/path/to/my-app/node_modules/mongodb/lib/collection.js:74
            pkFactory: db.options?.pkFactory ?? utils_1.DEFAULT_PK_FACTORY,
                                  ^

SyntaxError: Invalid or unexpected token
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)

Node.js v18.12.1
[nodemon] app crashed - waiting for file changes before starting...

Whats the difference?

From the release notes:

8.2.0

  • Added support for FedRAMP sandbox tenants for OAuth2 and installation callbacks

8.1.1

  • Update dependency sqlite3 to v5.1.6
  • Update dependency @aws-sdk/client-dynamodb to v3.398.0

8.1.0

  • Update dependency mongodb to v5. Note: only the Node.js driver was updated and the new version is still compatible with MongoDB 3.6 and later.

It looks like the update to mongodb v5 in ACE 8.1.0 broke things.

:point_right: I’m not even using anything to do with mongodb, so why is my app now broken with ACE v8.2.0?

Note: I’m running the app using esm using the following watch-server in package.json:

"watch-server": "NODE_ENV=development nodemon -r dotenv/config -r esm app.js",

Aside, here’s my abridged config.json:

{
  development: {
    ...
    "store": {
      "adapter": "sequelize",
      "type": "postgres",
      "url": "postgres://username:@localhost:5432/gaij"
      // assumed that your development machine user is `username` and you're running Postgres w/o a password
    },
  },
  ...
}
1 Like

Looks like MongoDB Nodejs Driver 5 introduced optional chaining in the codebase that requires Node.js v14 or higher. What version of Node.js are you running? Would it be possible for you to update? And what version of esm are you running?

2 Likes

@jweiss Thanks for your reply.

I am currently running node 18.12.1 & esm 3.2.25.

My abridged package.json:

{
  ...
  "engines": {
    "node": "18.12.1",
    "npm": "8.19.2"
  },
  ...
  "dependencies": {
    ...
    "esm": "^3.2.25",
    ...
  },
  ...
}

Hi @david ,
the problem is probably with ESM. ESM does not support optional chaining.
You can remove ESM if your code dos not mix ES6 and require, or if your files are called with suffix .mjs and .cjs or you use the module specifier in your package.json.

1 Like