Skip to content

Instantly share code, notes, and snippets.

@edwardkenfox
Created May 17, 2018 00:23
Show Gist options
  • Save edwardkenfox/91f8688b9486f9a4af3e12d5f4ff9b06 to your computer and use it in GitHub Desktop.
Save edwardkenfox/91f8688b9486f9a4af3e12d5f4ff9b06 to your computer and use it in GitHub Desktop.
sendBeacon attempt 0 with 0 bytes succeeded
...
sendBeacon attempt 362 with 65703 bytes succeeded
sendBeacon attempt 363 with 65703 bytes failed
let bytes = 0
for (let i = 0; i < 1000; i++) {
const payload = Array(i).join('a')
const result = navigator.sendBeacon('http://localhost:9000', payload)
if (result) {
bytes += i
console.info(`sendBeacon attempt ${i} with ${bytes} bytes succeeded`)
} else {
console.warn(`sendBeacon attempt ${i} with ${bytes} bytes failed`)
break
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment