1'use strict'; 2 3require('../common'); 4 5// Regression tests for https://github.com/nodejs/node/issues/40693 6 7const assert = require('assert'); 8const dgram = require('dgram'); 9const { AsyncLocalStorage } = require('async_hooks'); 10 11dgram.createSocket('udp4') 12 .on('message', function(msg, rinfo) { this.send(msg, rinfo.port); }) 13 .on('listening', function() { 14 const asyncLocalStorage = new AsyncLocalStorage(); 15 const store = { val: 'abcd' }; 16 asyncLocalStorage.run(store, () => { 17 const client = dgram.createSocket('udp4'); 18 client.on('message', (msg, rinfo) => { 19 assert.deepStrictEqual(asyncLocalStorage.getStore(), store); 20 client.close(); 21 this.close(); 22 }); 23 client.send('Hello, world!', this.address().port); 24 }); 25 }) 26 .bind(0); 27