I have quite a bit time figuring out why some of the tests were failing (in ipfs/js-ipfs#3081) on Firefox. Turns out structured clone algorithm throws when HTTError is being posted over message channel
|
class HTTPError extends Error { |
|
constructor (response) { |
|
super(response.statusText) |
|
this.name = 'HTTPError' |
|
this.response = response |
|
} |
|
} |
There are multiple issues:
- Firefox does not yet support native Error types https://bugzilla.mozilla.org/show_bug.cgi?id=1556604
- Even with the above resolved
response: Response still creates an issue.
I'm not sure what the appropriate course of action would be here, but here are few options:
- Making
response non-enumerable property, which would be ignored.
- Instead of attaching
Response instance extend HTTPError to include relevant data e.g:
class HTTPError extends Error {
constructor (response) {
super(response.statusText)
this.name = 'HTTPError'
this.statusText = response.statusText
this.responseType = response.type
this.url = response.url
this.status = response.status
this.redirected = response.redirected
}
}
I have quite a bit time figuring out why some of the tests were failing (in ipfs/js-ipfs#3081) on Firefox. Turns out structured clone algorithm throws when
HTTErroris being posted over message channeljs-ipfs-utils/src/http.js
Lines 21 to 27 in 4cc3826
There are multiple issues:
response: Responsestill creates an issue.I'm not sure what the appropriate course of action would be here, but here are few options:
responsenon-enumerable property, which would be ignored.Responseinstance extendHTTPErrorto include relevant data e.g: