Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

bad proxy will raise exception: TypeError: options.request.emit is not a function #40

@sshxmz

Description

@sshxmz

When I use an agent created by tunnel with proxy, if the proxy is not reachable, wrong exception raised.

Simple codes:

let a = tunnel.httpOverHttp({proxy: {host: 'nosuch.host.com', port: 8080}});
    return got(anurl, {agent: a})
    .then( res => {
        if (res.statusCode === 200) return res.body;
        else throw new Error('http status ' + res.statusCode + ', ' + res.body);
    }); 

exception raised:

TypeError: options.request.emit is not a function
    at ClientRequest.onError (/home/xxx/nodejs/proxylib/node_modules/tunnel/lib/tunnel.js:183:21)
    at Object.onceWrapper (events.js:300:26)
    at ClientRequest.emit (events.js:210:5)
    at Socket.socketErrorListener (_http_client.js:406:9)
    at Socket.emit (events.js:210:5)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

But EHOSTNOTFOUND or ENETWORK are expected error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions