GeezerVison is showing github.com — test: verify tracePromise does not do runStores · nodejs/node@4b4336c
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-diagnostics-channel-tracing-channel-promise-run-stores.js +11-4Lines changed: 11 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,16 +9,23 @@ const assert = require('assert'); |
9 | 9 | const channel = dc.tracingChannel('test'); |
10 | 10 | const store = new AsyncLocalStorage(); |
11 | 11 |
|
12 | | -const context = { foo: 'bar' }; |
| 12 | +const firstContext = { foo: 'bar' }; |
| 13 | +const secondContext = { baz: 'buz' }; |
13 | 14 |
|
14 | 15 | channel.start.bindStore(store, common.mustCall(() => { |
15 | | - return context; |
| 16 | + return firstContext; |
| 17 | +})); |
| 18 | + |
| 19 | +channel.asyncStart.bindStore(store, common.mustNotCall(() => { |
| 20 | + return secondContext; |
16 | 21 | })); |
17 | 22 |
|
18 | 23 | assert.strictEqual(store.getStore(), undefined); |
19 | 24 | channel.tracePromise(common.mustCall(async () => { |
20 | | - assert.deepStrictEqual(store.getStore(), context); |
| 25 | + assert.deepStrictEqual(store.getStore(), firstContext); |
21 | 26 | await setTimeout(1); |
22 | | - assert.deepStrictEqual(store.getStore(), context); |
| 27 | + // Should _not_ switch to second context as promises don't have an "after" |
| 28 | + // point at which to do a runStores. |
| 29 | + assert.deepStrictEqual(store.getStore(), firstContext); |
23 | 30 | })); |
24 | 31 | assert.strictEqual(store.getStore(), undefined); |