How to Fix MongoDB Error 90 (CallbackCanceled)
You see mongodb error 90 when the database engine cancels an internal callback. To fix it, wait for cluster recovery and retry the failed app operation. In the official system specs, code 90 has the name CallbackCanceled. It falls under the CancellationError group inside the database engine. This failure means an async task stopped before it could finish its work. It often shows up during node shutdowns, primary stepdowns, or sharp network drops. Root causes of mongodb error 90 in a cluster
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You see mongodb error 90 when the database engine cancels an internal callback. To fix it, wait for cluster recovery and retry the failed app operation.
In the official system specs, code 90 has the name CallbackCanceled. It falls under the CancellationError group inside the database engine. This failure means an async task stopped before it could finish its work. It often shows up during node shutdowns, primary stepdowns, or sharp network drops.
Root causes of mongodb error 90 in a cluster
Database nodes use internal callbacks to track async tasks across the cluster. When a node changes state, it must clear out its waiting tasks. The engine cancels those waiting callbacks and returns code 90 to the caller.
A common trigger is a replica set election or a planned node restart. When a primary node steps down, it stops active work right away. Any internal callback waiting on a network reply or disk lock gets canceled. Your app driver then receives the CallbackCanceled response from the server.
Network drops between cluster members also cause this specific cancellation error. In a sharded cluster, a router talks to many shard nodes at once. If a shard node drops off the network, the router cancels the callback. High memory load or slow disks can also push tasks past their time limits.
How to check and fix callback cancellations in production
Start by reading the server logs around the exact time of the failure. Look for replica set stepdowns, node restarts, or broken network links between hosts. If a planned maintenance task ran at that moment, the error is normal. Your app should catch the cancellation error and retry the request after a pause.
Next, check if a slow query or heavy write caused a timeout. Engineers often log in to a production node to inspect collection stats and indexes. Keep database permissions tight when your team investigates these live production issues. MongoDB grants access through roles that allow specific actions on defined resources.
MongoDB Authentication & Authorization + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
A role applies to its home database and works down to the collection level. Do not hand out broad write roles just to inspect a failing cluster. Assign the built-in read role to engineers who check live cluster health. The read role allows read access to all non-system collections in that database.
It includes actions like find, listCollections, listIndexes, dbStats, collStats, and changeStream. It does not allow insert, update, remove, or dropCollection actions on your data. Reserve the readWrite role for approved scripts that must fix data or build indexes. Note that Atlas database users have different built-in roles than self-hosted users. Both deployment types still build their roles from the same privilege actions.
How to prevent repeated callback errors in your app
You can lower the rate of code 90 errors with good app rules. Make sure your client driver uses sensible time limits for all network calls. Add retry logic with a short backoff delay for all read and write calls. When a primary node steps down, the retry will hit the new primary.
Schedule heavy index builds and node upgrades during quiet traffic hours. Watch disk speed and memory use across all replica set members every day. Fixing slow queries early stops internal tasks from piling up during peak load. If your team queries user tables during checks, mask emails and phone numbers. Data masking rewrites matched fields in results so sensitive values stay safe.
Check MongoDB commands and documents on the wire
MongoDB roles and SCRAM login decide who opens a session. They do not check single commands or redact sensitive fields inside returned documents. With hoop.dev, you run an open-source proxy, a sidecar for your MongoDB, inline in the MongoDB wire protocol. On every command an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
Before a command runs, hoop.dev guardrails check its effect and refuse banned drops or writes with MongoDB error code 13, or hold risky commands for approval. On the way back, hoop.dev data masking rewrites sensitive fields in returned documents in memory, and every verdict is logged. See the open-source code on GitHub.
Frequently asked questions
What does CallbackCanceled mean in MongoDB?
CallbackCanceled is the official name for error code 90 in the database engine. It belongs to the CancellationError group and means an internal async task stopped early.
Does mongodb error 90 mean my data is corrupt?
No, this error does not point to corrupt data on your storage disks. The engine stops the callback to protect data safety during a shutdown or stepdown.
Which role should engineers use to check a node after error 90?
Give engineers the built-in read role on the target database for safe checks. It lets them run dbStats, collStats, listIndexes, and find without any write access.
Related guides
In this post