Parse Server has stopped working in production

For the past week, my parse server deployment on Amazon has crashed. I thought that it could’ve been a deprecation issue so I decided to install the updated version of parse server from this url: https://github.com/MoralisWeb3/Moralis-JS-SDK/tree/main/demos/parse-server
and run it locally on my machine.

I configured it properly and created the builds. The server seems to be running fine. However when calling Moralis functions from my frontend, I get “invalid functions” error on almost all the functions. Refer to attached screenshots.

Keep in mind that I have not changed my frontend code. It was running perfectly before the parse server started creating issues.

Hi @LoneS58

Can you please share the current moralis sdk packages which you have on client?

Here is my package.json file. I am using some version of moralis-v1. All of the functions were applied from their documentation around 6 months ago.

{
  "name": "treasurehunttoken",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@types/node": "20.2.5",
    "@types/parse": "^3.0.4",
    "@types/react": "18.2.8",
    "@types/react-dom": "18.2.4",
    "@walletconnect/web3-provider": "^1.8.0",
    "axios": "^1.4.0",
    "bootstrap": "5.1.3",
    "dotenv": "^16.1.3",
    "eslint": "8.42.0",
    "eslint-config-next": "13.4.4",
    "jquery": "^3.7.0",
    "moralis-v1": "^1.13.0",
    "next": "13.4.4",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-moralis": "^1.4.2",
    "sweetalert2": "^11.7.10",
    "tweetnacl": "^1.0.3",
    "tweetnacl-util": "^0.15.1",
    "typescript": "5.1.3",
    "web3": "^1.10.0"
  }
}

For reference, this is my parse server’s package.json after I have posted the client side’s package.json.

{
  "name": "demo-parse-server",
  "version": "1.0.0",
  "main": "dist/index.js",
  "private": true,
  "dependencies": {
    "@codemirror/language": "^0.20.0",
    "@moralisweb3/common-core": "^2.24.0",
    "cors": "^2.8.5",
    "dotenv": "^16.0.1",
    "envalid": "7.3.1",
    "express": "^4.18.1",
    "express-rate-limit": "^6.5.1",
    "graphql": "^16.6.0",
    "graphql-ws": "^5.10.1",
    "mongoose": "^8.1.1",
    "moralis": "^2.24.0",
    "parse-dashboard": "^4.1.4",
    "parse-server": "^5.4.0"
  },
  "devDependencies": {
    "@moralisweb3/eslint-config": "^1.0.3",
    "@types/cors": "^2.8.13",
    "@types/node": "^18.11.18",
    "@typescript-eslint/eslint-plugin": "^5.48.2",
    "@typescript-eslint/parser": "^5.48.2",
    "eslint": "^8.32.0",
    "eslint-plugin-etc": "^2.0.2",
    "eslint-plugin-import": "^2.27.5",
    "mongodb-runner": "^4.9.0",
    "prettier": "^2.8.0",
    "ts-node": "^10.9.1",
    "typescript": "^4.9.4"
  },
  "scripts": {
    "dev": "ts-node src/index.ts",
    "build": "tsc",
    "gen:lockfile": "yarn install --mode update-lockfile",
    "lint": "eslint --ext .js,.ts .",
    "format": "prettier --write 'src/**/*.{js,ts}'",
    "dev:db-start": "mongodb-runner start",
    "dev:db-stop": "mongodb-runner stop"
  }
}

Thanks for the details. As per the sdk releases there was no recent changes to it and you do have the latest sdk versions as per your package.json.

The error Invalid function getPluginSpecs and getNFTOwners could arise only if you are somehow importing an older Moralis sdk in your project. Can you verify by any chance you have an cdn import of an older Moralis sdk?
Also make sure you are importing the Moralis from moralis-v1 package.

Yes, I am importing Moralis from moralis-v1 package in my frontend client. There are no cdn imports of the sdk. Double checked that from my end. However, can you send a link to working up-to-date implementation of demo parse-server and sample client side so I can try looking into this and analyze if there are any errors in my code implementation. Lastly yes, I am importing Moralis as:
image

This is the original error that originated in my server. It was somehow related to ngrok.


To reproduce this error, try running the code after building it you may face ngrok error. To make it work, I had uninstalled ngrok and reinstalled it to a more recent version 5.0.0 and the server used to run until it suddenly stopped working with the attacked error in the previous image:

Coming back to the latest parse-server version, I can see that a demo html file is also facing same issues. It was provided by moralis in one of the previous versions of parse-server. I am attaching the index.html file for reference as well. I am still getting Invalid function getNativeBalance error here. I am certain that this is no longer a client side issue.

<!DOCTYPE html>
<html>
  <head>
    <title>Vanilla Boilerplate</title>
    <script src="https://unpkg.com/moralis-v1/dist/moralis.js"></script>
  </head>

  <body>
    <h1>Moralis Hello World!</h1>

    <button id="btn-login">Moralis Metamask Login</button>
    <button id="btn-logout">Logout</button>
    <button id="call">call</button>

    <script type="text/javascript">
      /* Moralis init code */
      const serverUrl = 'http://localhost:1337/server';
      const appId = 'aaa';
      Moralis.start({ serverUrl, appId });

      /* Authentication code */
      async function handleAuth(provider) {
        await Moralis.enableWeb3({
          throwOnError: true,
          provider,
        });

        const { account, chainId } = Moralis;

        if (!account) {
          throw new Error('Connecting to chain failed, as no connected account was found');
        }
        if (!chainId) {
          throw new Error('Connecting to chain failed, as no connected chain was found');
        }

        const { message } = await Moralis.Cloud.run('requestMessage', {
          address: account,
          chain: parseInt(chainId, 16),
          network: 'evm',
        });

        await Moralis.authenticate({
          signingMessage: message,
          throwOnError: true,
        }).then((user) => {
          console.log(user);
        });
      }

      async function logOut() {
        await Moralis.User.logOut();
        console.log('logged out');
      }

      document.getElementById('btn-login').onclick = () => handleAuth('metamask');
      document.getElementById('btn-logout').onclick = logOut;
      document.getElementById('call').onclick = async () => {
        // get BSC native balance for a given address
        const options = {
          chain: 'bsc',
          address: '0x3d6c0e79a1239df0039ec16Cc80f7A343b6C530e',
          to_block: '1234',
        };
        const balance = await Moralis.Web3API.account.getNativeBalance(options);
        console.log(balance);
      };
    </script>
  </body>
</html>

Here is the github folder of the latest parser server backend.

Please try with this.

Just tried setting up the server. Used both node 18 and 20 (stable versions):
Ran following commands:

npm install
npm run build
npm run dev

But ended up with an NgrokClientError:

Can you once try running ngrok http 4040 in your console to see if it can start the ngrok tunnel without any error?

Yes, ngrok is functioning via console without any issues.

I have tried your provided codebase on multiple systems and different internet connections as well. The issue seems to persist.

Can you once try npm i ngrok command?

As per old posts installing the ngrok and building the server again seems to have fixed some ngrok issues.

Performed the installation and ngrok package updated to: [email protected]
Please note that I utilized yarn instead of npm which oddly started the server. The same practice didn’t work for npm.

The issue regarding “Invalid Function” also got resolved.
Thank you for the amazing support.

1 Like

You will need to use ngrok authtoken as well. That resolved the issue with ngrok for me when server stopped working.

1 Like

You are actually right. When deploying to Elastic Bean Stalk, the issue was to assign an authtoken. The error did show up during deployment however what do you suggest? Should I specify installation process inside of .ebextensions folder?

I guess we are not able to host using AWS ElasticBeanStalk guide for production hosting. It needs to setup ngrok on the instances, assign an auth-token and then run the parse backend. Can we get a config file for this setup? Whatever I am attempting to do, is not working out when configuring .ebextensions to run initial scripts (of installing ngrok).

I guess ngrok is only used for localhost testing on the webhooks. You will not require ngrok in your production.
On production it should automatically use your server url for the webhook domain.

Thanks. I was able to host it successfully. Everything is up and running however there is one problem. Few days ago(almost 7 days ago), when you suggested the correct repository for the backend, I was able to run the parse backend on my local machine. I was able to load puzzles on my site (NFTs) however now I am not able to view them. Seems like a very strange issue. The site was never interacted with nor were any new puzzles (NFTs) introduced.

Attached is a picture of all the NFTs appearing on 1st Feb 2024:


None of these are popping up any longer:

I am utilizing two calls to Moralis:
Moralis.Web3API.token.getNFTOwners
Moralis.Web3API.token.reSyncMetadata

Were there any updates made to any of these Moralis functions since they do return the NFTs but they are not updated(or SYNCED although the status field claims them to be in sync)?

Can you share the wallet address and chain value that you are using with getNFTOwners?

Also, check if there are any errors in your browser or server console.