Home > OS >  Getting UnhandledPromiseRejectionWarning: Error: write EPROTO when running my async await function i
Getting UnhandledPromiseRejectionWarning: Error: write EPROTO when running my async await function i

Time:09-26

I was running the below code without any issue up until this afternoon, I did not change or update anything, not sure what is causing this:

async function getStocks(){

    const { data } = await axios.get('https://gist.githubusercontent.com/graffixnyc/8c363d85e61863ac044097c0d199dbcc/raw/7d79752a9342ac97e4953bce23db0388a39642bf/stocks.json')
    return data // this will be the array of people objects
}

async function abc(){
    let a = await getStocks()
    console.log(a)
}

abc()

It used to render the entire data from the JSON file but now throws the below error:

(node:1860) UnhandledPromiseRejectionWarning: Error: write EPROTO 14520:error:1408F10B:SSL ` 
routines:ssl3_get_record:wrong version 
number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:`

I am not sure which dependency has the wrong version since I did not update the code nor made any changes.

CodePudding user response:

The data on the website sent an invalid response, so the issue was not in the code but the website data itself.

CodePudding user response:

Try adding Try Catch to your functions.

  • Related