| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| 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); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments