node/test/parallel/test-diagnostics-channel-tracing-channel-run-stores.js
Stephen Belanger fe751df537
lib: add tracing channel to diagnostics_channel
PR-URL: https://github.com/nodejs/node/pull/44943
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
2023-03-31 17:40:30 +00:00

22 lines
577 B
JavaScript

'use strict';
const common = require('../common');
const { AsyncLocalStorage } = require('async_hooks');
const dc = require('diagnostics_channel');
const assert = require('assert');
const channel = dc.tracingChannel('test');
const store = new AsyncLocalStorage();
const context = { foo: 'bar' };
channel.start.bindStore(store, common.mustCall(() => {
return context;
}));
assert.strictEqual(store.getStore(), undefined);
channel.traceSync(common.mustCall(() => {
assert.deepStrictEqual(store.getStore(), context);
}));
assert.strictEqual(store.getStore(), undefined);