Skip to content

Mongodb breaks AsyncLocalStorage context spread #3186

@kas84

Description

@kas84
  • Node.js Version: v15.6.0
  • OS: MacOS Big Sur 11.1 (20C69)

I am having an issue using async hooks where the callback API of both mongodb and mariadb return undefined when used inside the callback (they work fine in the promise API though).

On mongodb when using useUnifiedTopology option set to true, sets the store correctly on the first run, but on subsequent requests, you still get the first store.
This is most likely a bug with their drivers, but, can somebody point me out in the right direction of what could be causing this?

I've built a sample app with mongodb: https://github.com/kas84/MongoDBCallbacksAsyncLocalStorage

[0.21756164732220062] request received
[0.21756164732220062] request received setTimeout
[undefined] request callback received
[0.21756164732220062] request promise received


When used with {useUnifiedTopology:true} , instead of undefined, you get the store, but on subsequent requests, you still get the first store

[0.7697388970645624] request received
[0.7697388970645624] request received setTimeout
[0.7697388970645624] request callback received
[0.7697388970645624] request promise received


[0.6329185718150439] request received
[0.6329185718150439] request received setTimeout
[0.7697388970645624] request callback received
[0.6329185718150439] request promise received


[0.2698320081709449] request received
[0.2698320081709449] request received setTimeout
[0.2698320081709449] request promise received
[0.7697388970645624] request callback received

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions