Hi there,
I’m building a dApp using Moralis and one of the main feature is being able to mint and notify the user of the successful transaction on the UI.
I’m using your event sync feature to update the database once the transaction is received and confirmed.
However, the platform seem to be syncing very slowly, sometimes hours later of the confirmation I see on Rinkeby scan.
I was wondering if you could shine a light on the frequency of the sync between the chain and the moralis platform and suggest if there is a way to speed it up.
Is this delay only happening in the test network? Can it depend on the fact that the server CPU and ram shows 100% ? Non sure why that’s happening because I’m the only one testing the dApp at the moment and there are no many requests being sent.
Many thanks for your help,
Enrico
Hi, can you share your server url?
does this seem familiar to you?
{"_objCount":130229,"className":"Created","id":"ziSlwXdKghmOU5Nj6qdrhxU5"}
Yes, it’s one of the tables I created to store the NFT metadata
Not sure if it helps but I’m using an aftersave cloud function to update the “Created” class after the “FullyMinted” class is synced
Moralis.Cloud.afterSave("FullyMinted", async (request) => {
const logger = Moralis.Cloud.getLogger();
const uid = parseInt(request.object.get("uid"));
logger.info(uid);
const q = new Moralis.Query("Created");
q.equalTo("parentAddress", request.object.get("parentAddress"));
q.equalTo("parentTokenID", request.object.get("parentTokenID"));
var results = await q.first();
logger.info(results);
if(results){
request.object.set("gifUrl", results.get("gifUrl"));
request.object.set("staticImageUrl", results.get("staticImageUrl"));
request.object.set("parentAddress", results.get("parentAddress"));
request.object.set("parentTokenID", results.get("parentTokenID"));
request.object.set("parentNftImageUrl", results.get("parentNftImageUrl"));
request.object.set("parentNftThumbUrl", results.get("parentNftThumbUrl"));
results.set("minted", true);
await results.save();
return await request.object.save();
}else{
console.error("this teekey has no metadata yet");
}
});
return await request.object.save();
may generate an infinite loop if afterSave will be called again
Thanks. I remove the return and tried to run the sync job but I still can’t see the old events.
Should I restart the server? Create a new sync event?
You can try to restart the server
I restarted and tried to sync again but no luck. I will try setting up new event sync with a new class
Once I create a new event sync it pulled all historical data and also was able to pull the first new mint very quickly. However the second time it didn’t work and it’s stuck again.
Is it possible the problem is related to the fact that I’m modifying the schema (adding extra fields) to the Class used for the sync event in the aftersave cloud function? Maybe I’m not supposed to do that
I still see things like {"_objCount":1642,"className":"Created","id":"wn3vwyRGuWUXkypGB6pRlmu9"}
It looks like you still have an infinite loop
same thing now with {"_objCount":10929,"className":"Created","id":"XBp1yO5iepGMTIcTyK0sGlkA"}
I removed all “await” from the afterSave function and it seems to be syncing now
Can you please let me know if you still see infinite loops going on? That will be obviously a concern in terms of performances
I still see them now:
{"_objCount":95093,"className":"Created","id":"QlxQItxuCpnrE8aIYpWRVSZ7"}
{"_objCount":95095,"className":"Created","id":"kp6B3RZ3grGsjsfbOaRYZL3l"}
{"_objCount":95096,"className":"Created","id":"XBp1yO5iepGMTIcTyK0sGlkA"}
What is _objCount? I can see those objects in the created Class but not sure what objCount means
it looks to be how many times that loop iterated, now it is {"_objCount":300728,"className":"Created","id":"QlxQItxuCpnrE8aIYpWRVSZ7"}