Skip to content
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

Speed Test randomly fails #36

Open
trickstival opened this issue Jun 3, 2024 · 1 comment
Open

Speed Test randomly fails #36

trickstival opened this issue Jun 3, 2024 · 1 comment

Comments

@trickstival
Copy link
Contributor

trickstival commented Jun 3, 2024

I am using SpeedTest on a normal front-end web app. Every now and then it randomly gives me errors.
Those errors do not happen all the time. I keep getting them if I try to re-run the tests during the same browser session. If I refresh the page, the errors are gone and only happen again after a while. I tried to create a new instance of SpeetTest to mitigate that behavior, but the errors keep popping up.

Those include:

Error fetching https://speed.clousflare.com/__down?bytes=0:
TypeError: Cannot read properties of undefined (reading 'transferSize')


// Or

Error in network meter Connection error while measuring download:
Connection failed to https://speed.cloudflare.com/__down?bytes=100000. Gave up after 20 retries.

I inspected the network tab, and all requests were responded with status 200, so I suppose it is not a problem with the network.

Then I tried to debug the issue, and it looks like performance.getEntriesByName(url) returns an empty array. I found a PR that attempted to fix a similar problem but for node.js: #24
In that issue you mentioned it is a problem with the fetch implementation, but I am using native fetch, since I am on the browser and window.fetch returns native code, and not some polyfill.

Screenshot 2024-06-03 at 11 36 03

Screenshot 2024-06-03 at 11 26 38

Screenshot 2024-06-03 at 10 21 22

Screenshot 2024-06-03 at 11 30 04

Screenshot 2024-06-03 at 11 23 55

Here are the settings I am using:

function createTestObject() {
  return new SpeedTest({
    autoStart: false,
    bandwidthFinishRequestDuration: 800,
    measureDownloadLoadedLatency: false,
    measurements: [
      { type: 'latency', numPackets: 1 }, // initial latency estimation
      { type: 'download', bytes: 1e5, count: 1, bypassMinDuration: true }, // initial download estimation
      { type: 'latency', numPackets: 3 },
      { type: 'download', bytes: 1e5, count: 1 },
      { type: 'download', bytes: 1e6, count: 1 },
      { type: 'upload', bytes: 1e5, count: 1 },
      { type: 'upload', bytes: 1e6, count: 1 },
      { type: 'download', bytes: 1e7, count: 1 },
      { type: 'upload', bytes: 1e7, count: 4 },
      { type: 'download', bytes: 2.5e7, count: 4 },
      { type: 'upload', bytes: 2.5e7, count: 4 },
      { type: 'download', bytes: 1e8, count: 7 },
      { type: 'latency', numPackets: 2 },
      { type: 'upload', bytes: 5e7, count: 7 },
      { type: 'download', bytes: 2.5e8, count: 9 },
      { type: 'upload', bytes: 5e8, count: 9 }
    ]
  })
}

This is a problem because the speed test does not work until the user refreshes the page.
More info about the environment were the tests were run:

Google Chrome 125.0.6422.114 (Official Build) (arm64)
Revision 457d70149965cebad452f7e37e8b5ec5b6dde5b4-refs/branch-heads/6422_76@{#5}
OS macOS Version 14.4.1 (Build 23E224)
JavaScript V8 12.5.227.9

All tests were run using chrome with the device toolbar set to iPhone 12 Pro. I would guess that it doesn't affect the Performance API, but I figured it could be a good idea to mention

@s3krit
Copy link

s3krit commented Jun 27, 2024

I am also running into this error. I cannot make rhyme nor reason for when this bug appears. I have reduced the config to a bare minimum in order more effectively test it:

const measurements = [
  { type: 'download', bytes: 1e5, count: 1, bypassMinDuration: true }, // initial download estimation
];

I am using Firefox 127.0.2 on MacOS Sonoma 14.5 but have also run into the same error on Chrome.

As can be seen in the following screenshot, the initial speedtest works (my app logs the results to console currently), but the second one fails with the same errors as @trickstival (the message being different is just because I'm using firefox - my log messages are the same as theirs on Chrome).

Screenshot 2024-06-27 at 13 43 52

Edit: hmm it looks like we're running into the same issue as #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants