mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
PR-URL: https://github.com/nodejs/node/pull/60150 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
28 lines
780 B
JavaScript
28 lines
780 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
// Regression tests for https://github.com/nodejs/node/issues/40693
|
|
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
const { AsyncLocalStorage } = require('async_hooks');
|
|
|
|
net
|
|
.createServer((socket) => {
|
|
socket.write('Hello, world!');
|
|
socket.pipe(socket);
|
|
})
|
|
.listen(0, common.mustCall(function() {
|
|
const asyncLocalStorage = new AsyncLocalStorage();
|
|
const store = { val: 'abcd' };
|
|
asyncLocalStorage.run(store, common.mustCall(() => {
|
|
const client = net.connect({ port: this.address().port });
|
|
client.on('data', common.mustCall(() => {
|
|
assert.deepStrictEqual(asyncLocalStorage.getStore(), store);
|
|
client.end();
|
|
this.close();
|
|
}));
|
|
}));
|
|
}));
|