faro-web-sdk: Error when sending data to the server when body size > 64kb and keepalive fetch option enable.

Description

The issue come from the keepalive options in the FetchTransport: https://github.com/grafana/faro-web-sdk/blob/88011e78770c1821a81203c46966b6032addc1ec/packages/web-sdk/src/transports/fetch/transport.ts#L55

When removing it the bug disapear.

This bug only happen when:

Screenshot from 2023-05-15 17-31-28

Steps to reproduce

Using all informations said above to configure faro and your project.

Expected behavior

Trace corretly exported.

Actual behavior

Trace are not exported because of the error screenshot in description

Environment

  • SDK version: 1.0.2
  • SDK instrumentations: 1.0.2
  • Device type: computer
  • Device name: Dell inspiron
  • OS: Ubuntu 20.04
  • Browser: Chrome latest

Demo

It is working fine without customizing splitChunks on the same projet with a npm run serve in local. (Possibility that is not working with a build as it’s the default configuration)

If I copy paste the load as curl in terminal it is working fine. If I copy past as fetch and use it directly in my code it’s working fine.

If I use the SimpleSpanProcessor it’s working.

The request block in pending even if the promise already rejected: Screenshot from 2023-05-15 18-25-26

Other call to grafana-agent in the same page are working fine.

In the zone.js:975 file from the stack trace the line is: return patchDelegate(this, arguments); If I do a console.log(patchDelegate, this, arguments) I get: Screenshot from 2023-05-15 18-34-26

Important to note the Exception: TypeError: in the callee do not appear just here but in other above call so it can be a wrong path to follow

In the fetch.js:233 file from the stack trace the line is: return original.apply(this, args); -> The issue STILL happen when we remove the fetch instrumentation If I do a console.log(original, original.apply, this, args) I get: Screenshot from 2023-05-15 18-41-44

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

Hey thanks a lot @alioshr

Even though I have isolated faro instances, when I unmount a remote App and switch to another one I still see requests being sent to the collector from the unmounted “isolated” instance.

With keepalive enable fetch will send all remaining/pending requests even a app is unmounted or a user navigates away from a page. This is to ensure that no data gets lost.

Why might turning keepAlive off stop the errors? Because Although leaving the app where the isolated instance is + turning keepAlive: false still keeps the fetch requests from the isolated instances active. So not sure how is it helping

Yes I’m also very confused by this problem.

My current idea is that we may run into the the body size limit for keepalive requests (64kiB). If this limit is reached fetch returns a network error.

No good news yet but we’ll fix it eventually.

My current idea is that we may run into the the body size limit for keepalive requests (64kiB). If this limit is reached fetch returns a network error.

Hi @codecapitano ❤️. Thank you for so much help on this meanwhile =) I have been bugging you everywhere

Shouldn’t we expect the usage of isolate: true along with keepalive: false to result in fully isolated faro instances? Shouldn’t stop transporting whatever was kept active when isolating the instance & leaving an app?

Hey @alioshr no no it’s absolutely no bugging at all! We at Grafana and of course myself too are very very happy about all the input we receive. It’s absolutely stunning for us how the community cares and invests time to help us improve things. ❤️ So please keep asking and raise issues 😃

Shouldn’t we expect the usage of isolate: true along with keepalive: false to result in fully isolated faro instances?

In case you mean by “fully isolated” that all pending requests are dropped once the app is unmounted or a user leaves the page then I would say yes. But this would also mean that you loose some data points aka signals.

Cheers, Marco

Hi @AMontagu sorry unfortunately I have no updates on this. We already thought internally about hoe to tackle it and have some ideas.

A precondition is to tackle this issue and then we can build on top of it: https://github.com/grafana/faro-web-sdk/issues/261

Hello @codecapitano

Have you any update on this ? we miss a lot of trace and log because of this limitation.

@codecapitano I think you hit the good point for 64kiB. As it happen only when trace are at a specific size.

We had some issues to reproduce because in an empty project we didn’t reach this size. Busy until friday but will definitely try to flood traces with a lot of data to see if it raise the issue.