Uh oh!
There was an error while loading. Please reload this page.
lib: add defaultValue and name options to AsyncLocalStorage - #57766
lib: add defaultValue and name options to AsyncLocalStorage#57766jasnell wants to merge 2 commits into
Conversation
Uh oh!
There was an error while loading. Please reload this page.
mcollina
commented
Apr 5, 2025
I don't think we should do this right now because the spec is still Stage 2, while AsyncLocalStorage is stable. Those fields could easily be scrapped/changed, and we would be stuck with them. |
This comment was marked as outdated.
This comment was marked as outdated.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
0612c1f to
4cf070fCompare
I wouldn't have opened the PR if I didn't think they were useful independently of the Specifically, if we were prematurely implementing |
Uh oh!
There was an error while loading. Please reload this page.
4ef2590 to
3e68ac6CompareThe upcoming `AsyncContext` specification adds a default value and name
to async storage variables. This adds the same to `AsyncLocalStorage`
to promote closer alignment with the pending spec.
```js
const als = new AsyncLocalStorage({
name: 'foo',
defaultValue: 123,
});
console.log(als.name); // 'foo'
console.log(als.getStore()); // 123
```
Refs: https://github.com/tc39/proposal-async-context/blob/master/spec.html3e68ac6 to
69a25e2Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Chengzhong Wu <legendecas@gmail.com>
The upcoming `AsyncContext` specification adds a default value and name
to async storage variables. This adds the same to `AsyncLocalStorage`
to promote closer alignment with the pending spec.
```js
const als = new AsyncLocalStorage({
name: 'foo',
defaultValue: 123,
});
console.log(als.name); // 'foo'
console.log(als.getStore()); // 123
```
Refs: https://github.com/tc39/proposal-async-context/blob/master/spec.html
PR-URL: #57766
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>jasnell
commented
Apr 7, 2025
Landed in a369818 |
The upcoming `AsyncContext` specification adds a default value and name
to async storage variables. This adds the same to `AsyncLocalStorage`
to promote closer alignment with the pending spec.
```js
const als = new AsyncLocalStorage({
name: 'foo',
defaultValue: 123,
});
console.log(als.name); // 'foo'
console.log(als.getStore()); // 123
```
Refs: https://github.com/tc39/proposal-async-context/blob/master/spec.html
PR-URL: #57766
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>The upcoming `AsyncContext` specification adds a default value and name
to async storage variables. This adds the same to `AsyncLocalStorage`
to promote closer alignment with the pending spec.
```js
const als = new AsyncLocalStorage({
name: 'foo',
defaultValue: 123,
});
console.log(als.name); // 'foo'
console.log(als.getStore()); // 123
```
Refs: https://github.com/tc39/proposal-async-context/blob/master/spec.html
PR-URL: #57766
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>aduh95
commented
May 6, 2025
Tests are not passing on v22.x-staging, this would require a manual backport if we want it on 22.x |
The upcoming `AsyncContext` specification adds a default value and name
to async storage variables. This adds the same to `AsyncLocalStorage`
to promote closer alignment with the pending spec.
```js
const als = new AsyncLocalStorage({
name: 'foo',
defaultValue: 123,
});
console.log(als.name); // 'foo'
console.log(als.getStore()); // 123
```
Refs: https://github.com/tc39/proposal-async-context/blob/master/spec.html
PR-URL: nodejs#57766
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
The upcoming
AsyncContextspecification adds a default value and name to async storage variables. This adds the same toAsyncLocalStorageto promote closer alignment with the pending spec.Refs: https://github.com/tc39/proposal-async-context/blob/master/spec.html