-
Notifications
You must be signed in to change notification settings - Fork 240
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
[BUG] Beacon sender causes flood of thousands of requests on page unload #2195
Comments
yikes! good catch. This scenario only occurs during |
At this point the next scheduled release (because of the upcoming holidays) will not be until early next year (Feb '24). |
Hmm, however, looking at the code history, it appears that this bug was not introduced until v3.0.4 (so 3.0.3 doesn't have the same issue)...
So this might just be a case that you have a backlog of events all of which cannot be sent (because the sendBeacon API has a 64kb limitation) |
You are right. That's my mistake. I was looking at our package.json without realizing that our package-lock.json actually references version 3.0.4. So we are on 3.0.4. As a workarround, we will downgrade to 3.0.3 until the bug is fixed. Thanks! |
for people, who are integrating the sdk by injecting a script tag in the header of the page provided here: rather than using the npm version (because supposedly that nets better tracking, as the sdk would be loaded sooner) currently it is @MSNev would like to get a confirmation on if this is how this issue should be worked around until this bug is fixed. |
Correct, this is discussed (not quite so succinctly as above) here in the main readme https://github.com/Microsoft/ApplicationInsights-JS#module-formats Additional details |
I downgraded to @microsoft/applicationinsights-web": "^3.0.3" & "3.0.2" but I still see excessive number of requests. Any other workaround? |
Hello, |
Yes and No, if you call flush this will attempt to send the requests via a XMLHttpRequest, however, this can have several side-effects
|
Looking back at the history, it appears that the PR that introduced this change is #2113, which first appears in v3.0.4, so downgrading to either This situation only occurs when the "final" |
This should resolve the following issue #1195 Related issue microsoft/ApplicationInsights-JS#2195
This should resolve the following issue #1195 Related issue microsoft/ApplicationInsights-JS#2195
Description/Screenshot
Sometimes the AI SDK causes 10s of thousands of requests when the page is getting unloaded, which causes the page to become very unresponsive. Upon further investigation the problem seems to arise from the _beaconSender function in Sender.ts and specifically the fallback logic if the initial beacon send was not successful:
https://github.com/microsoft/ApplicationInsights-JS/blob/19e8131c7f979a0c4ec2069a56ea7e37a0d82c15/channels/applicationinsights-channel-js/src/Sender.ts#L865C22-L865C35
As I understand the function, it will try to split up the payload by using the payload.oriPayload array and sending the items of that array individually. However the for loop uses data.length instead of oriPayload.length as the index bound. data is however a string representation of the payload, so the loop basically iterates over each character of that payload, which in our case is multiples of 10k bytes. Also within the loop, the variable thePayload is initialized using
payload[lp]
instead oforiPayload[lp]
.Steps to Reproduce
Create a payload that cannot be send completely using the beacon API.
Expected behavior
Payload is split and send successfully.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: