GoogleChromeLabs / GoogleChromeLabs/quicklink

Limit does not work if value is >= 4 *and* throttle property is set

Open
#235 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
11.3k
Forks
429
PR merge metrics
No merged PRs in 30d

Description

This was really hard to track down and is kinda weird, so bear with me.

If the following is true, the `limit` option is not respected
- the `limit` option is greater or equal to `4`
- the `throttle` option is set

I posted a quick 1 minute video of this at https://youtu.be/hb5hBDZqTdY

**To Reproduce**
Create the following HTML file, and then watch the network tab as *all* of the links are prefetched.

```html



Prefetch: Basic Usage

Lorem, ipsum.
Eligendi, mollitia.
Tempore, optio.
Perspiciatis, modi!
Voluptates, quas!
Quibusdam, laborum.
Veritatis, aspernatur?
Obcaecati, totam!
Repellat, ex.
Laboriosam, explicabo.
Saepe, harum.
Aperiam, ad.
Ut, quae!
Et, sint.
Facere, alias!
Exercitationem, voluptatem.
Sed, odio?
Dicta, eum.
Commodi, veniam.
Quod, similique!



// Limit does not work if it is >=4 *and* throttle property is set.
quicklink.listen({
limit: 4,
throttle: 3
});

```

**Expected behavior**
I expect only 4 links to be prefetched

**Version:**
- OS w/ version: MacOS 11.2.1 Big Sur
- Browser w/ version: Version 90.0.4430.212 (Official Build) (x86_64)

**Additional context, screenshots, screencasts**

What's weird is that if the `throttle` option is not set, it works properly. Also, if the `limit` option is set to `3` or below, it will work properly even with the `throttle` option set.

Video showing the problem in action: https://youtu.be/hb5hBDZqTdY

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.