mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 23:43:09 +01:00
1b8bfddf89
Fixes: https://github.com/nodejs/node/issues/40693 Signed-off-by: Darshan Sen <darshan.sen@postman.com> PR-URL: https://github.com/nodejs/node/pull/40741 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
27 lines
790 B
JavaScript
27 lines
790 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
|
|
// Regression tests for https://github.com/nodejs/node/issues/40693
|
|
|
|
const assert = require('assert');
|
|
const dgram = require('dgram');
|
|
const { AsyncLocalStorage } = require('async_hooks');
|
|
|
|
dgram.createSocket('udp4')
|
|
.on('message', function(msg, rinfo) { this.send(msg, rinfo.port); })
|
|
.on('listening', function() {
|
|
const asyncLocalStorage = new AsyncLocalStorage();
|
|
const store = { val: 'abcd' };
|
|
asyncLocalStorage.run(store, () => {
|
|
const client = dgram.createSocket('udp4');
|
|
client.on('message', (msg, rinfo) => {
|
|
assert.deepStrictEqual(asyncLocalStorage.getStore(), store);
|
|
client.close();
|
|
this.close();
|
|
});
|
|
client.send('Hello, world!', this.address().port);
|
|
});
|
|
})
|
|
.bind(0);
|