undici icon indicating copy to clipboard operation
undici copied to clipboard

Client network socket disconnected before secure TLS connection was established

Open Probabilities opened this issue 1 year ago • 3 comments

Bug Description

I get an error when using a proxy. I cannot catch the error so it crashes my app.

My code:

    try{
        const req = await request('https://discord.com/api/v9/invites/discord', {
            query: {
                inputValue: 'discord',
                with_counts: true,
                with_expiration: true
            },
            dispatcher: agent
        })

        const data = await req.body.json()

        return data
    }catch{
        console.log('An error occurred.')
        return false
    }

Reproducible By

I sent lots of requests with my proxy and on the odd chance it will throw this error

Expected Behavior

Error should be caught.

Logs & Screenshots

Environment

OS: Windows 11 Node Version: 18.13.0

Additional context

I can restart my app and the whole process will happen again. I just want to catch the error lol so I can handle it.

Probabilities avatar Mar 24 '24 12:03 Probabilities

Can you provide an Minimum Reproducible Example that isolates the issue you are describing?

metcoder95 avatar Mar 25 '24 09:03 metcoder95

What is the error? msg? stack?

ronag avatar Mar 25 '24 09:03 ronag

Can you provide an Minimum Reproducible Example that isolates the issue you are describing?

    try{
        const req = await request('https://discord.com/api/v9/invites/discord', {
            query: {
                inputValue: 'discord',
                with_counts: true,
                with_expiration: true
            },
            dispatcher: agent
        })

        const data = await req.body.json()

        return data
    }catch{
        console.log('An error occurred.')
        return false
    }

Probabilities avatar Mar 25 '24 14:03 Probabilities

Sorry but that's not enough to reproduce your use case, you mentioned proxy so maybe there might be the root cause as the request works accordingly.

Any stack, error, message?

metcoder95 avatar Mar 26 '24 09:03 metcoder95