Skip to content

async generators do not capture async context #42237

Open
@devsnek

Description

@devsnek

tested on v17 but i don't suspect that matters much.

'use strict';

const { AsyncLocalStorage } = require('async_hooks');

const s = new AsyncLocalStorage();

async function normal() {
  console.log('async fn', s.getStore());
}

async function* gen() {
  console.log('async gen', s.getStore());
}

s.run('hello', normal);

s.run('hello', gen).next();

output:

async fn hello
async gen undefined

/cc @nodejs/async_hooks

i'm assuming this probably will need some sort of effort on the v8 side?

Metadata

Metadata

Assignees

No one assigned

    Labels

    async_hooksIssues and PRs related to the async hooks subsystem.async_local_storageAsyncLocalStorageconfirmed-bugIssues with confirmed bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions