From a44ccacb43f132ecafcf1cb87aa3062d4aae4135 Mon Sep 17 00:00:00 2001 From: LiviaMedeiros Date: Fri, 18 Apr 2025 04:15:17 +0800 Subject: [PATCH] http2: give name to promisified `connect()` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/57916 Reviewed-By: Antoine du Hamel Reviewed-By: Vinícius Lourenço Claro Cardoso Reviewed-By: James M Snell --- lib/internal/http2/core.js | 5 +++-- test/parallel/test-util-promisify-custom-names.mjs | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index d7d7fb99ae6..18e10fbd16a 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -25,6 +25,7 @@ const { } = primordials; const { + assignFunctionName, assertCrypto, customInspectSymbol: kInspect, kEmptyObject, @@ -3395,7 +3396,7 @@ function connect(authority, options, listener) { // Support util.promisify ObjectDefineProperty(connect, promisify.custom, { __proto__: null, - value: (authority, options) => { + value: assignFunctionName('connect', function(authority, options) { return new Promise((resolve, reject) => { const server = connect(authority, options, () => { server.removeListener('error', reject); @@ -3404,7 +3405,7 @@ ObjectDefineProperty(connect, promisify.custom, { server.once('error', reject); }); - }, + }), }); function createSecureServer(options, handler) { diff --git a/test/parallel/test-util-promisify-custom-names.mjs b/test/parallel/test-util-promisify-custom-names.mjs index 79da972ae20..3540d20e262 100644 --- a/test/parallel/test-util-promisify-custom-names.mjs +++ b/test/parallel/test-util-promisify-custom-names.mjs @@ -1,4 +1,4 @@ -import '../common/index.mjs'; +import { hasCrypto } from '../common/index.mjs'; import assert from 'node:assert'; import { promisify } from 'node:util'; @@ -48,3 +48,11 @@ assert.strictEqual( promisify(child_process.execFile).name, 'execFile' ); + +if (hasCrypto) { + const http2 = await import('node:http2'); + assert.strictEqual( + promisify(http2.connect).name, + 'connect' + ); +}