defunctzombie / zuul

[UNMAINTAINED] multi-framework javascript browser testing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unhandled `socket hung up` introduced with http-proxy

cristiandouce opened this issue · comments

I keep getting this error code when running with zuul@3.8.0 and zuul-ngrok@3.0.0.

>> /Users/home/test-lib/node_modules/zuul/node_modules/http-proxy/lib/http-proxy/index.js:119
>>     throw err;
>>     ^
>> 
>> Error: socket hang up
>>     at createHangUpError (_http_client.js:203:15)
>>     at Socket.socketCloseListener (_http_client.js:235:23)
>>     at emitOne (events.js:82:20)
>>     at Socket.emit (events.js:169:7)
>>     at TCP._onclose (net.js:469:12)
>> Exited with code: 1.

This doesn't happen with zuul@3.6.0, before the introduction of http-proxy. If you follow the line of the thrown error:

// ../zuul/node_modules/http-proxy/lib/http-proxy/index.js:119
ProxyServer.prototype.onError = function (err) {
  //
  // Remark: Replicate node core behavior using EE3
  // so we force people to handle their own errors
  //
  if(this.listeners('error').length === 1) {
    throw err;
  }
};

Yep I had seen this also, see https://github.com/defunctzombie/zuul/pull/256/files. I thought I fixed it but maybe not.

bouncy had attached a listener destroying the socket when error occurred by default. That behavior I didn't found in http-proxy module. Not sure either it's the desired behavior but at least there should be an error handler registered.

but at least there should be an error handler registered.

Do you know where we should register it, or if it's an http-proxy task? Maybe there's an issue in their github

@vvo I think maybe here.
Like it's said in http-proxy code comment:

  // Remark: Replicate node core behavior using EE3
  // so we force people to handle their own errors

They expect the users of the lib to handle the errors emitted.

Ok, do you think you can provide a PR to zuul to handle this?

Hey, just saw this issue. I fixed the same issue here (webtorrent/webtorrent.io@cd4cb63) recently. Hope this helps!