Created
May 17, 2018 00:23
-
-
Save edwardkenfox/91f8688b9486f9a4af3e12d5f4ff9b06 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sendBeacon attempt 0 with 0 bytes succeeded | |
... | |
sendBeacon attempt 362 with 65703 bytes succeeded | |
sendBeacon attempt 363 with 65703 bytes failed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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