Skip to content

Commit e283319

Browse files
committed
http: fix permanent deoptimizations
PR-URL: #12456 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 7a5bac5 commit e283319

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

‎lib/_http_agent.js‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,14 @@ Agent.prototype.getName = function getName(options){
130130
returnname;
131131
};
132132

133-
Agent.prototype.addRequest=functionaddRequest(req,options){
133+
Agent.prototype.addRequest=functionaddRequest(req,options,port/*legacy*/,
134+
localAddress/*legacy*/){
134135
// Legacy API: addRequest(req, host, port, localAddress)
135136
if(typeofoptions==='string'){
136137
options={
137138
host: options,
138-
port: arguments[2],
139-
localAddress: arguments[3]
139+
port,
140+
localAddress
140141
};
141142
}
142143

‎lib/_http_client.js‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ function ClientRequest(options, cb){
127127
'Expected "'+expectedProtocol+'"');
128128
}
129129

130-
constdefaultPort=options.defaultPort||
131-
this.agent&&this.agent.defaultPort;
130+
vardefaultPort=options.defaultPort||
131+
this.agent&&this.agent.defaultPort;
132132

133133
varport=options.port=options.port||defaultPort||80;
134134
varhost=options.host=validateHost(options.hostname,'hostname')||
@@ -226,7 +226,7 @@ function ClientRequest(options, cb){
226226

227227
varcalled=false;
228228

229-
constoncreate=(err,socket)=>{
229+
varoncreate=(err,socket)=>{
230230
if(called)
231231
return;
232232
called=true;
@@ -238,14 +238,15 @@ function ClientRequest(options, cb){
238238
this._deferToConnect(null,null,()=>this._flush());
239239
};
240240

241+
varnewSocket;
241242
if(this.socketPath){
242243
this._last=true;
243244
this.shouldKeepAlive=false;
244-
constoptionsPath={
245+
varoptionsPath={
245246
path: this.socketPath,
246247
timeout: this.timeout
247248
};
248-
constnewSocket=this.agent.createConnection(optionsPath,oncreate);
249+
newSocket=this.agent.createConnection(optionsPath,oncreate);
249250
if(newSocket&&!called){
250251
called=true;
251252
this.onSocket(newSocket);
@@ -270,7 +271,7 @@ function ClientRequest(options, cb){
270271
this._last=true;
271272
this.shouldKeepAlive=false;
272273
if(typeofoptions.createConnection==='function'){
273-
constnewSocket=options.createConnection(options,oncreate);
274+
newSocket=options.createConnection(options,oncreate);
274275
if(newSocket&&!called){
275276
called=true;
276277
this.onSocket(newSocket);

0 commit comments

Comments
(0)