1

My backend listens to events emitted from my Solana program to proccess certain events initiated by my client client-side.

Most of the time the events are received and handled correctly, but sometimes some transactions get missed and the program listener does not pick them up.

const subscriptionId = program.addEventListener("eventName", (event) => {
  // Handle event...
});

This is a big issue for my web application as its dependent on my backend capturing these events. I am using a paid Helius RPC as well so I figured it shouldn't be rate limiting issues etc.

What could I be doing wrong? Is a server listening to events being emitted from my Anchor/Solana program not the most robust/conventional approach?

What other way could I do this?

https://book.anchor-lang.com/anchor_in_depth/events.html

1 Answer 1

1

There are a few reasons for this to happen unfortunately. Websockets can be a little flaky.

For example, the old JS library is pretty opinionated about reconnect logic and doesn't allow you to specify your own logic for picking up anything that might be missed. You can look into the new JS library for better options there https://github.com/solana-labs/solana-web3.js?tab=readme-ov-file#message-gap-recovery

Typically, the more robust way to get all events to your backend would be through a Geyser plugin: https://docs.solanalabs.com/validator/geyser

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.