Skip to content

Commit 8f1aee9

Browse files
LiviaMedeirostargos
authored andcommitted
http2: give name to promisified connect()
PR-URL: #57916 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 7dabf07 commit 8f1aee9

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
@@ -25,6 +25,7 @@ const {
2525
} = primordials;
2626

2727
const {
28+
assignFunctionName,
2829
assertCrypto,
2930
customInspectSymbol: kInspect,
3031
kEmptyObject,
@@ -3395,7 +3396,7 @@ function connect(authority, options, listener) {
33953396
// Support util.promisify
33963397
ObjectDefineProperty(connect, promisify.custom, {
33973398
__proto__: null,
3398-
value: (authority, options) => {
3399+
value: assignFunctionName('connect', function(authority, options) {
33993400
return new Promise((resolve, reject) => {
34003401
const server = connect(authority, options, () => {
34013402
server.removeListener('error', reject);
@@ -3404,7 +3405,7 @@ ObjectDefineProperty(connect, promisify.custom, {
34043405

34053406
server.once('error', reject);
34063407
});
3407-
},
3408+
}),
34083409
});
34093410

34103411
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)