11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ciconst net = require('net'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_citmpdir.refresh(); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst { PerformanceObserver } = require('perf_hooks'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst entries = []; 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst obs = new PerformanceObserver(common.mustCallAtLeast((items) => { 151cb0ef41Sopenharmony_ci entries.push(...items.getEntries()); 161cb0ef41Sopenharmony_ci})); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ciobs.observe({ type: 'net' }); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci{ 211cb0ef41Sopenharmony_ci const server = net.createServer(common.mustCall((socket) => { 221cb0ef41Sopenharmony_ci socket.destroy(); 231cb0ef41Sopenharmony_ci })); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci server.listen(0, common.mustCall(async () => { 261cb0ef41Sopenharmony_ci await new Promise((resolve, reject) => { 271cb0ef41Sopenharmony_ci const socket = net.connect(server.address().port); 281cb0ef41Sopenharmony_ci socket.on('end', resolve); 291cb0ef41Sopenharmony_ci socket.on('error', reject); 301cb0ef41Sopenharmony_ci }); 311cb0ef41Sopenharmony_ci server.close(); 321cb0ef41Sopenharmony_ci })); 331cb0ef41Sopenharmony_ci} 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci{ 361cb0ef41Sopenharmony_ci const server = net.createServer(common.mustCall((socket) => { 371cb0ef41Sopenharmony_ci socket.destroy(); 381cb0ef41Sopenharmony_ci })); 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ci server.listen(common.PIPE, common.mustCall(async () => { 411cb0ef41Sopenharmony_ci await new Promise((resolve, reject) => { 421cb0ef41Sopenharmony_ci const socket = net.connect(common.PIPE); 431cb0ef41Sopenharmony_ci socket.on('end', resolve); 441cb0ef41Sopenharmony_ci socket.on('error', reject); 451cb0ef41Sopenharmony_ci }); 461cb0ef41Sopenharmony_ci server.close(); 471cb0ef41Sopenharmony_ci })); 481cb0ef41Sopenharmony_ci} 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_ciprocess.on('exit', () => { 511cb0ef41Sopenharmony_ci assert.strictEqual(entries.length, 1); 521cb0ef41Sopenharmony_ci entries.forEach((entry) => { 531cb0ef41Sopenharmony_ci assert.strictEqual(entry.name, 'connect'); 541cb0ef41Sopenharmony_ci assert.strictEqual(entry.entryType, 'net'); 551cb0ef41Sopenharmony_ci assert.strictEqual(typeof entry.startTime, 'number'); 561cb0ef41Sopenharmony_ci assert.strictEqual(typeof entry.duration, 'number'); 571cb0ef41Sopenharmony_ci assert.strictEqual(!!entry.detail.host, true); 581cb0ef41Sopenharmony_ci assert.strictEqual(!!entry.detail.port, true); 591cb0ef41Sopenharmony_ci }); 601cb0ef41Sopenharmony_ci}); 61