I wanted to update my worker removing the old deprecated MongoDB Atlas API, and I read that now Workers should support the MongoDB node.js driver, but I can't seam to make it work.
Everything is working fine on my local machine, I set the compatibility flags to
nodejs_compat
nodejs_compat
and compatibility date to
2025-05-05
2025-05-05
, but when I publish the worker I keep getting errors like:
- MongoDB operation error: MongoServerSelectionError: [unenv] net.createConnection is not implemented yet!- MongoDB operation error: Error: [unenv] dns.resolveSrv is not implemented yet!
- MongoDB operation error: MongoServerSelectionError: [unenv] net.createConnection is not implemented yet!- MongoDB operation error: Error: [unenv] dns.resolveSrv is not implemented yet!
In my package.json the versions of wrangler and mongodb are respectively
Previously I wrote about Why Cloudflare Workers Don’t Work With MongoDB, but since then the Cloudflare team has done some great work to add support for the missing Node.js features MongoDB’s driver required to operate successfully from Cloudflare Workers: