Skip to content

Commit 86cab8c

Browse files
committed
feat: emit warning for req.closed only once
1 parent caba351 commit 86cab8c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/request.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
'use strict';
44

5-
const { emitWarning } = require('node:process');
5+
const { emitWarning } = require('process');
66
var url = require('url');
77
var sprintf = require('util').format;
88

@@ -846,12 +846,16 @@ function patch(Request) {
846846
* @function closed
847847
* @returns {Boolean} is closed
848848
*/
849+
let closedDeprecatedWarned = false;
849850
Request.prototype.closed = function closed() {
850-
emitWarning(
851-
'restify req.closed is deprecated, will be removed on Restify 10',
852-
'RestifyDeprecationWarning',
853-
'RestifyDEPReqClosed'
854-
);
851+
if (!closedDeprecatedWarned) {
852+
emitWarning(
853+
'restify req.closed is deprecated, will be removed on v10',
854+
'RestifyDeprecationWarning',
855+
'RestifyDEPReqClosed'
856+
);
857+
closedDeprecatedWarned = true;
858+
}
855859
var self = this;
856860
return self.connectionState() === 'close';
857861
};

0 commit comments

Comments
 (0)