From 3370d30b2f835a4603aee83b5a7ff4597788c14c Mon Sep 17 00:00:00 2001 From: Constantine Kim Date: Sat, 9 Oct 2021 01:58:09 +0900 Subject: [PATCH] doc: fix asyncLocalStorage.run() description The description that store is not available when asynchronous operation is created within the callback is not accurate --- doc/api/async_context.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/api/async_context.md b/doc/api/async_context.md index 7c949f65857920..78cfc08461049d 100644 --- a/doc/api/async_context.md +++ b/doc/api/async_context.md @@ -223,8 +223,9 @@ added: * `...args` {any} Runs a function synchronously within a context and returns its -return value. The store is not accessible outside of the callback function or -the asynchronous operations created within the callback. +return value. The store is not accessible outside of the callback function. +The store is accessible to any asynchronous operations created within the +callback. The optional `args` are passed to the callback function. @@ -238,6 +239,9 @@ const store = { id: 2 }; try { asyncLocalStorage.run(store, () => { asyncLocalStorage.getStore(); // Returns the store object + setTimeout(() => { + asyncLocalStorage.getStore(); // Returns the store object + }, 200); throw new Error(); }); } catch (e) {