Skip to content

RangeError: Invalid status code: 0 #1080

Closed
@philios33

Description

@philios33

Hi

I have no idea how this happens but I am getting this crash dump when I proxy some requests. It's especially annoying because I can't catch the Exception in my code as it happens in the http-proxy code.

RangeError: Invalid status code: 0
    at ServerResponse.writeHead (_http_server.js:192:11)
    at Array.writeStatusCode (/var/www/node-preview-proxy/node_modules/http-proxy/lib/http-proxy/passes/web-outgoing.js:113:11)
    at ClientRequest.<anonymous> (/var/www/node-preview-proxy/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:157:20)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:472:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:105:23)
    at Socket.socketOnData (_http_client.js:361:20)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)

Could we add some sanity check in here? I noticed that _http_server.js does this.

statusCode |= 0;
  if (statusCode < 100 || statusCode > 999)
    throw new RangeError(`Invalid status code: ${statusCode}`);

Using version 1.15.2 of http-proxy

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions