This type of error generally happens when you abruptly kill your running instance of mongo-db.
For example if you are using mongo-db version 8.0 then to avoid this error first -
Stop the mongo-db service
brew services stop [email protected]
Start the mongo-db service
brew services start [email protected]
This should resolve the issue.