Using `Moralis.start()` for long-running or consistent back-to-back calls

TLDR; What is the recommended mechanism of “connection” for long-running or back-to-back activity via Moralis SDK?

So, I’ve written a few apps recently (in various frameworks) that require numerous Moralis interactions. Rather than call .start() for every single item, in most cases I’ve (preemptively) created an application single-connection-singleton that .start() once and continues to run (with appropriate error checks of course). To date, I have an application that’s run for over a month with minimal issues.

That said, what is the actual recommended mechanism for handling long-running or constant back-to-back transactions/activity? Is the API ok with calling .start() constantly for hours/days on end or is the single-connection-singleton approach recommended? :thinking:

I think that you will get an error if you try to call again Moralis.start() after it was called already at least once.

If you are using moralis v2 sdk it shouldn’t matter if you called it only once for a long time as it is only using the API key that you set initially in order to make other API calls.

1 Like