Skip to content

Commit

Permalink
feat: emit warning for req.closed only once
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarchini committed Apr 12, 2023
1 parent caba351 commit 86cab8c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

'use strict';

const { emitWarning } = require('node:process');
const { emitWarning } = require('process');
var url = require('url');
var sprintf = require('util').format;

Expand Down Expand Up @@ -846,12 +846,16 @@ function patch(Request) {
* @function closed
* @returns {Boolean} is closed
*/
let closedDeprecatedWarned = false;
Request.prototype.closed = function closed() {
emitWarning(
'restify req.closed is deprecated, will be removed on Restify 10',
'RestifyDeprecationWarning',
'RestifyDEPReqClosed'
);
if (!closedDeprecatedWarned) {
emitWarning(
'restify req.closed is deprecated, will be removed on v10',
'RestifyDeprecationWarning',
'RestifyDEPReqClosed'
);
closedDeprecatedWarned = true;
}
var self = this;
return self.connectionState() === 'close';
};
Expand Down

0 comments on commit 86cab8c

Please sign in to comment.