lib/websocket.js
function abortHandshake(websocket, stream, message) {
  websocket.readyState = WebSocket.CLOSING;

  const err = new Error(message);
  Error.captureStackTrace(err, abortHandshake);

  if (stream.setHeader) {
    stream.abort();
    stream.once('abort', websocket.emitClose.bind(websocket));
    websocket.emit('error', err);
  } else {
    stream.destroy(err);
    stream.once('error', websocket.emit.bind(websocket, 'error'));
    stream.once('close', websocket.emitClose.bind(websocket));
  }
}
function abortHandshake(websocket, stream, message) {
  websocket.readyState = WebSocket.CLOSING;

  const err = new Error(message);
  Error.captureStackTrace(err, abortHandshake);

  if (stream.setHeader) {
    stream.abort();
    stream.once('abort', websocket.emitClose.bind(websocket));
    websocket.emit('error', err);
  } else {
    stream.destroy(err);
    stream.once('error', websocket.emit.bind(websocket, 'error'));
    stream.once('close', websocket.emitClose.bind(websocket));
  }
}
function abortHandshake ( websocket , stream , message ) { websocket . readyState = WebSocket . CLOSING ; const err = new Error ( message ) ; Error . captureStackTrace ( err , abortHandshake ) ; if ( stream . setHeader ) { stream . abort ( ) ; stream . once ( 'abort' , websocket . emitClose . bind ( websocket ) ) ; websocket . emit ( 'error' , err ) ; } else { stream . destroy ( err ) ; stream . once ( 'error' , websocket . emit . bind ( websocket , 'error' ) ) ; stream . once ( 'close' , websocket . emitClose . bind ( websocket ) ) ; } }
Abort the handshake and emit an error.

@param {WebSocket} websocket The WebSocket instance
@param {(http.ClientRequest|net.Socket)} stream The request to abort or the
socket to destroy
@param {String} message The error message
@private
Abort the handshake and emit an error .