[SOLVED] Integrating Steams into self hosted Parse Server

I’ve been trying to integrate the new streams into a self-hosted parse server. I cloned the package linked in the video tutorial (Migrating to self-hosted Parse server). Following this post: Using event-syncs in Moralis SDK v2 & Parse Server, I’m successfully able to trigger a webhook via a stream and add new data in my parse server.

The problem arises when I try to update the data (when confirmed changes to ‘true’), I get this error repeatedly:

error: TypeError: Cannot read properties of undefined (reading 'type') {"code":1,"stack":"Error: TypeError: Cannot read properties of undefined (reading 'type')\n    at C:\\Users\\Sid\\Documents\\GitHub\\ethernalelves\\ethernal-elves-backend\\node_modules\\parse-server\\src\\Controllers\\DatabaseController.js:1307:27\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)"}       
error: TypeError: Cannot read properties of undefined (reading 'type') {"code":1,"stack":"Error: TypeError: Cannot read properties of undefined (reading 'type')\n    at C:\\Users\\Sid\\Documents\\GitHub\\ethernalelves\\ethernal-elves-backend\\node_modules\\parse-server\\src\\Controllers\\DatabaseController.js:1307:27\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)"}       
error: TypeError: Cannot read properties of undefined (reading 'type') {"code":1,"stack":"Error: TypeError: Cannot read properties of undefined (reading 'type')\n    at C:\\Users\\Sid\\Documents\\GitHub\\ethernalelves\\ethernal-elves-backend\\node_modules\\parse-server\\src\\Controllers\\DatabaseController.js:1307:27\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)"}       
error: TypeError: Cannot read properties of undefined (reading 'type') {"code":1,"stack":"Error: TypeError: Cannot read properties of undefined (reading 'type')\n    at C:\\Users\\Sid\\Documents\\GitHub\\ethernalelves\\ethernal-elves-backend\\node_modules\\parse-server\\src\\Controllers\\DatabaseController.js:1307:27\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)"}       
error: TypeError: Cannot read properties of undefined (reading 'type') {"code":1,"stack":"Error: TypeError: Cannot read properties of undefined (reading 'type')\n    at C:\\Users\\Sid\\Documents\\GitHub\\ethernalelves\\ethernal-elves-backend\\node_modules\\parse-server\\src\\Controllers\\DatabaseController.js:1307:27\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)"}       
error while inserting logs {}

On further investigation, (after logging the console output), the process seems to fail when query.find or query.first runs. Interestingly, adding a new row works just fine, the query does not work inside parse-server.

I have tried a number of things, including instaling parse (parse/node) and properly initializing it with the server url, appid and masterkey.

Is anyone expecting something similar? Have tried a lot of things, nothing seems to work - please help!

Code follows:

const Parse = require('parse/node');

import config from '../config';

export async function parseUpdate(tableName: string, object: any) {
    // Check if object exists in db    
    const TableClassName = Parse.Object.extend(tableName);
    const query = new Parse.Query(TableClassName);
    
    query.equalTo('transaction_hash', object.transaction_hash);
    query.equalTo('log_index', object.log_index);

    const result = await query.first();
    console.log("result,",  result);
    if (result) {
      // Loop through object's keys
      for (const key in object) {
        result.set(key, object[key]);
      }
      return result?.save(null, { useMasterKey: true });
    } else {
      // Create new object
      const newObject = new Parse.Object(tableName);
      for (const key in object) {
        newObject.set(key, object[key]);
      }
      return newObject.save(null, { useMasterKey: true });
    }

  }```

we are working on a new tutorial for parse server and streams API that may help you, it should be ready today

1 Like

you could try to test it now, but it may have some changes

I’ve found the issue - I tried making some queries to other tables with no problem. This version of Parse does not support Decimal128 datatypes - https://community.parseplatform.org/t/how-to-read-write-decimal128-data-type-field-in-mongo-using-parse/2558

The nitro moralis servers had decimals for uint256 events so I think that is the issue.

There is a patch for that decimal support in a repo specific to streams api. You could also stop using decimals.

That would be much better - will look for the patch. Thanks

Hi There, is the tutorial for parse server and streams API ready?
If yes could you please share the link.