lib: add defaultValue and name options to AsyncLocalStorage#57766
lib: add defaultValue and name options to AsyncLocalStorage#57766jasnell wants to merge 2 commits intonodejs:mainfrom
Conversation
|
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.
0612c1f to
4cf070f
Compare
I wouldn't have opened the PR if I didn't think they were useful independently of the Specifically, if we were prematurely implementing |
4ef2590 to
3e68ac6
Compare
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
3e68ac6 to
69a25e2
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
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>
|
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: nodejs#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>
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>
|
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 `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