Skip to content

async_hook gives older context. #38017

Open
@ronak-zymr

Description

@ronak-zymr

Hello,

We are using async hook in our node application. We want to track each and every request's context as an when it comes. we are creating a chain of request context in one map based on the trigger ID and async ID.

Find the below code for creating a chain.

init(asyncId, type, triggerAsyncId, _resource) {
        if (this.tracked.has(triggerAsyncId)) {
            this.tracked.set(asyncId, this.tracked.get(triggerAsyncId));
        }
 }

Here in the above snippet "this.tracked" is map and we are creating a chain of context inside this map and also using this map to get the context based on the asyncID.

It works fine until we move one page to another page very quickly.

When we move from one page to another page very quickly and try to get the context object from our map using the async ID it gives the older context, and the chain breaks.

We believe that out page is called before async hook init finishes its job...

Let me know if you need any more information on this.

Thanks in advance
Ronak Pandya

Metadata

Metadata

Assignees

No one assigned

    Labels

    async_hooksIssues and PRs related to the async hooks subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions