Read and Write Errors Detection

Hi guys, I have one question please… Is it possible to detect read error in MongoDB using Node.JS library?
I think write errors could be detected with “acknowledged” field, but is there a chance to detect read errors?
If yes, how please?
This is very important for me, my app is working on many concurrent connections, around 120, and I’ve found not all writes are saved correctly, I will improve this by tracking acknowledged field, and retrying… but I’m very curious about read errors.

Thank you for your help,

Hello @David_David2 ,

MongoDB supports retryable reads, which means that if a read operation fails, MongoDB will automatically retry the operation a configurable number of times. You can enable retryable reads by setting the retryReads option to true when you create your MongoDB client. Please refer to Retryable Reads docs to learn more.

Furthermore, you can use the callback function or Promises in Nodejs to detect read errors using the Node.js MongoDB driver.

This will help you in better understanding of the overall error handling while read operations.
Please feel free to ask any additional questions, would be happy to help! :slightly_smiling_face:


1 Like

Thank you very much for your help!

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.