Oh, interesting. Presumably good old, synchronous, browser-style `globalObject.localStorage` wouldn'

Oh, interesting. Presumably good old, synchronous, browser-style globalObject.localStorage wouldn't work? If so, using AsyncLocalStorage, am I right that it would look something like this, to store a global property for later reading downstream?
Upstream file:
import { AsyncLocalStorage } from 'node:async_hooks';
const fooStore = new AsyncLocalStorage();
fooStore.run('bar'); //<-- running in some async middleware

Downstream file:
import { AsyncLocalStorage } from 'node:async_hooks';
const fooStore = new AsyncLocalStorage();
const fooVal = fooStore.getStore(); //"bar"
Was this page helpful?