Skip to content

Commit b064433

Browse files
LiviaMedeirosaduh95
authored andcommitted
http2: give name to promisified connect()
PR-URL: #57916 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 6816d77 commit b064433

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/internal/http2/core.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const {
2424
} = primordials;
2525

2626
const {
27+
assignFunctionName,
2728
assertCrypto,
2829
customInspectSymbol: kInspect,
2930
kEmptyObject,
@@ -3376,7 +3377,7 @@ function connect(authority, options, listener) {
33763377
// Support util.promisify
33773378
ObjectDefineProperty(connect, promisify.custom, {
33783379
__proto__: null,
3379-
value: (authority, options) => {
3380+
value: assignFunctionName('connect', function(authority, options) {
33803381
return new Promise((resolve, reject) => {
33813382
const server = connect(authority, options, () => {
33823383
server.removeListener('error', reject);
@@ -3385,7 +3386,7 @@ ObjectDefineProperty(connect, promisify.custom, {
33853386

33863387
server.once('error', reject);
33873388
});
3388-
},
3389+
}),
33893390
});
33903391

33913392
function createSecureServer(options, handler) {

test/parallel/test-util-promisify-custom-names.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import '../common/index.mjs';
1+
import { hasCrypto } from '../common/index.mjs';
22
import assert from 'node:assert';
33
import { promisify } from 'node:util';
44

@@ -48,3 +48,11 @@ assert.strictEqual(
4848
promisify(child_process.execFile).name,
4949
'execFile'
5050
);
51+
52+
if (hasCrypto) {
53+
const http2 = await import('node:http2');
54+
assert.strictEqual(
55+
promisify(http2.connect).name,
56+
'connect'
57+
);
58+
}

0 commit comments

Comments
 (0)