Ky: TypeError o.response is undefined

Created on 27 Apr 2020  路  2Comments  路  Source: sindresorhus/ky

The error.response on https://github.com/sindresorhus/ky/blob/master/index.js#L374
is undefined when the error is AbortError.

ky

Should I catch that exception in the retry function?

bug

Most helpful comment

This looks like a legit bug in Ky, unfortunately. The error may not have a response on it, which we don't check before attempting to clone it.

In hindsight, I'm kind of regretting https://github.com/sindresorhus/ky/pull/201. People should almost certainly just use error.response. This shortcut provides very little value. Most people are going to destructure the options anyway. I also think that, from the hook's perspective, it's more obvious that options.error.response may be undefined, as opposed to options.response.

All 2 comments

I'm sorry. I could not reproduce this error on Google Chrome / Safari thus might be my Firefox is broken.

This looks like a legit bug in Ky, unfortunately. The error may not have a response on it, which we don't check before attempting to clone it.

In hindsight, I'm kind of regretting https://github.com/sindresorhus/ky/pull/201. People should almost certainly just use error.response. This shortcut provides very little value. Most people are going to destructure the options anyway. I also think that, from the hook's perspective, it's more obvious that options.error.response may be undefined, as opposed to options.response.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sarneeh picture sarneeh  路  6Comments

davalapar picture davalapar  路  6Comments

Splact picture Splact  路  7Comments

jacob-fueled picture jacob-fueled  路  3Comments

luxferresum picture luxferresum  路  7Comments