11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_cirequire('../common'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci// Regression tests for https://github.com/nodejs/node/issues/40693 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst assert = require('assert'); 81cb0ef41Sopenharmony_ciconst net = require('net'); 91cb0ef41Sopenharmony_ciconst { AsyncLocalStorage } = require('async_hooks'); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_cinet 121cb0ef41Sopenharmony_ci .createServer((socket) => { 131cb0ef41Sopenharmony_ci socket.write('Hello, world!'); 141cb0ef41Sopenharmony_ci socket.pipe(socket); 151cb0ef41Sopenharmony_ci }) 161cb0ef41Sopenharmony_ci .listen(0, function() { 171cb0ef41Sopenharmony_ci const asyncLocalStorage = new AsyncLocalStorage(); 181cb0ef41Sopenharmony_ci const store = { val: 'abcd' }; 191cb0ef41Sopenharmony_ci asyncLocalStorage.run(store, () => { 201cb0ef41Sopenharmony_ci const client = net.connect({ port: this.address().port }); 211cb0ef41Sopenharmony_ci client.on('data', () => { 221cb0ef41Sopenharmony_ci assert.deepStrictEqual(asyncLocalStorage.getStore(), store); 231cb0ef41Sopenharmony_ci client.end(); 241cb0ef41Sopenharmony_ci this.close(); 251cb0ef41Sopenharmony_ci }); 261cb0ef41Sopenharmony_ci }); 271cb0ef41Sopenharmony_ci }); 28