Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPError causes structured cloning algorithm to throw #48

Open
Gozala opened this issue Jun 19, 2020 · 2 comments
Open

HTTPError causes structured cloning algorithm to throw #48

Gozala opened this issue Jun 19, 2020 · 2 comments
Labels
help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) P3 Low: Not priority right now

Comments

@Gozala
Copy link
Contributor

Gozala commented Jun 19, 2020

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:

  1. Firefox does not yet support native Error types https://bugzilla.mozilla.org/show_bug.cgi?id=1556604
  2. 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:

  1. Making response non-enumerable property, which would be ignored.
  2. 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
      }
    }
@Gozala Gozala added the need/triage Needs initial labeling and prioritization label Jun 19, 2020
@welcome

This comment has been minimized.

@jacobheun jacobheun added the kind/bug A bug in existing code (including security flaws) label Jul 9, 2020
@achingbrain
Copy link
Member

Perhaps option 2? Could you take a look at the code and see if we even use the response anywhere an if so, which properties we use?

@jacobheun jacobheun added need/author-input Needs input from the original author and removed need/triage Needs initial labeling and prioritization labels Jul 16, 2020
@lidel lidel added help wanted Seeking public contribution on this issue P3 Low: Not priority right now and removed need/author-input Needs input from the original author labels May 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) P3 Low: Not priority right now
Projects
None yet
Development

No branches or pull requests

4 participants