Skip to content

xhook breaks navigator.sendBeacon(url, formData)  #151

@BenoitZugmeyer

Description

@BenoitZugmeyer

When using your library on a website, every usages of navigator.sendBeacon(url, formData) are broken.

It seems that your library is patching the FormData object. It works fine with fetch and xhr because it is also patching them. But it is still an issue with sendBeacon: the browser is receiving an unexpected Xhook instance and because it does not recognize it, just runs toString on the provided value which produces "[object Object]".

How to reproduce:

  • With xhook installed on a HTML document, run something like this:
const formData = new FormData()
formData.append("foo", "bar")
navigator.sendBeacon("/", formData)
  • Look at the request payload in the devtools:
    • Actual:
      Screenshot 2022-07-29 at 17 43 51
    • Expected:
      Screenshot 2022-07-29 at 17 45 09

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions