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

feat: expose Retry-After and sublimit timeouts in RatelimitData #9864

Merged
merged 4 commits into from
Nov 12, 2023

Conversation

vladfrangu
Copy link
Member

@vladfrangu vladfrangu commented Oct 1, 2023

Please describe the changes this PR makes and why it should be merged:

Expose Retry-After header in RatelimitData/RatelimitError, as well as sublimit timeouts, if any are present, which can be used in cases to report to users they'll need to wait (think for the /guilds/:id/emojis route and its ratelimit)

Also brings RatelimitData in sync with what we log for the debug event (unintentional enhancement)

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating
  • This PR changes the library's interface (methods or parameters added)

@vercel
Copy link

vercel bot commented Oct 1, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
discord-js ❌ Failed (Inspect) Nov 12, 2023 2:35pm
discord-js-guide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 12, 2023 2:35pm

@codecov
Copy link

codecov bot commented Oct 1, 2023

Codecov Report

Merging #9864 (390aeed) into main (62e6573) will increase coverage by 0.09%.
The diff coverage is 98.14%.

@@            Coverage Diff             @@
##             main    #9864      +/-   ##
==========================================
+ Coverage   59.23%   59.32%   +0.09%     
==========================================
  Files         237      237              
  Lines       16496    16536      +40     
  Branches     1237     1238       +1     
==========================================
+ Hits         9771     9810      +39     
- Misses       6680     6681       +1     
  Partials       45       45              
Flag Coverage Δ
brokers 63.16% <ø> (ø)
builders 98.69% <ø> (ø)
collection 99.28% <ø> (ø)
formatters 99.45% <ø> (ø)
guide 0.00% <ø> (ø)
next ∅ <ø> (∅)
proxy 75.00% <ø> (ø)
rest 92.82% <98.14%> (+0.07%) ⬆️
util 70.70% <ø> (ø)
utilities 100.00% <ø> (ø)
voice 63.64% <ø> (ø)
website 0.00% <ø> (ø)
ws 52.63% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
packages/rest/src/lib/errors/RateLimitError.ts 100.00% <100.00%> (ø)
packages/rest/src/lib/handlers/BurstHandler.ts 91.27% <100.00%> (+0.24%) ⬆️
packages/rest/src/lib/utils/types.ts 100.00% <100.00%> (ø)
...ackages/rest/src/lib/handlers/SequentialHandler.ts 87.71% <93.75%> (-0.01%) ⬇️

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

packages/rest/src/lib/utils/types.ts Show resolved Hide resolved
packages/rest/src/lib/utils/types.ts Outdated Show resolved Hide resolved
Copy link
Member

@ckohen ckohen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So close

packages/rest/src/lib/utils/types.ts Outdated Show resolved Hide resolved
packages/rest/src/lib/utils/types.ts Outdated Show resolved Hide resolved
Co-authored-by: ckohen <chaikohen@gmail.com>
@kodiakhq kodiakhq bot merged commit 81e7866 into main Nov 12, 2023
21 checks passed
@kodiakhq kodiakhq bot deleted the chore/add-reset-after-to-ratelimit-data branch November 12, 2023 14:36
Vylpes pushed a commit to Vylpes/card-drop that referenced this pull request Nov 27, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@discordjs/rest](https://discord.js.org) ([source](https://github.com/discordjs/discord.js)) | dependencies | minor | [`2.0.1` -> `2.2.0`](https://renovatebot.com/diffs/npm/@discordjs%2frest/2.0.1/2.2.0) |

---

### Release Notes

<details>
<summary>discordjs/discord.js (@&#8203;discordjs/rest)</summary>

### [`v2.2.0`](https://github.com/discordjs/discord.js/blob/HEAD/packages/rest/CHANGELOG.md#discordjsrest220---2023-11-17)

[Compare Source](https://github.com/discordjs/discord.js/compare/@discordjs/rest@2.1.0...@discordjs/rest@2.2.0)

#### Bug Fixes

-   Minify mainlib docs json ([#&#8203;9963](discordjs/discord.js#9963)) ([4b88306](discordjs/discord.js@4b88306))

#### Features

-   Present x-ratelimit-scope for 429s hit ([#&#8203;9973](discordjs/discord.js#9973)) ([6df233d](discordjs/discord.js@6df233d))

#### Typings

-   Use wrapper utilities ([#&#8203;9945](discordjs/discord.js#9945)) ([4bc1dae](discordjs/discord.js@4bc1dae))

### [`v2.1.0`](https://github.com/discordjs/discord.js/blob/HEAD/packages/rest/CHANGELOG.md#discordjsrest210---2023-11-12)

[Compare Source](https://github.com/discordjs/discord.js/compare/@discordjs/rest@2.0.1...@discordjs/rest@2.1.0)

#### Bug Fixes

-   **REST:** Strip webhook tokens ([#&#8203;9723](discordjs/discord.js#9723)) ([cf49f40](discordjs/discord.js@cf49f40))

#### Documentation

-   Fix "its" typo ([#&#8203;9825](discordjs/discord.js#9825)) ([c50809e](discordjs/discord.js@c50809e))
-   **create-discord-bot:** Support bun in create-discord-bot ([#&#8203;9798](discordjs/discord.js#9798)) ([7157748](discordjs/discord.js@7157748))

#### Features

-   Expose Retry-After and sublimit timeouts in RatelimitData ([#&#8203;9864](discordjs/discord.js#9864)) ([81e7866](discordjs/discord.js@81e7866))
-   **CDN:** Support emoji size ([#&#8203;9787](discordjs/discord.js#9787)) ([778df45](discordjs/discord.js@778df45))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/101
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
Vylpes pushed a commit to Vylpes/vylbot-app that referenced this pull request Dec 18, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@discordjs/rest](https://discord.js.org) ([source](https://github.com/discordjs/discord.js)) | dependencies | minor | [`2.0.1` -> `2.2.0`](https://renovatebot.com/diffs/npm/@discordjs%2frest/2.0.1/2.2.0) |

---

### Release Notes

<details>
<summary>discordjs/discord.js (@&#8203;discordjs/rest)</summary>

### [`v2.2.0`](https://github.com/discordjs/discord.js/blob/HEAD/packages/rest/CHANGELOG.md#discordjsrest220---2023-11-17)

[Compare Source](https://github.com/discordjs/discord.js/compare/@discordjs/rest@2.1.0...@discordjs/rest@2.2.0)

#### Bug Fixes

-   Minify mainlib docs json ([#&#8203;9963](discordjs/discord.js#9963)) ([4b88306](discordjs/discord.js@4b88306))

#### Features

-   Present x-ratelimit-scope for 429s hit ([#&#8203;9973](discordjs/discord.js#9973)) ([6df233d](discordjs/discord.js@6df233d))

#### Typings

-   Use wrapper utilities ([#&#8203;9945](discordjs/discord.js#9945)) ([4bc1dae](discordjs/discord.js@4bc1dae))

### [`v2.1.0`](https://github.com/discordjs/discord.js/blob/HEAD/packages/rest/CHANGELOG.md#discordjsrest210---2023-11-12)

[Compare Source](https://github.com/discordjs/discord.js/compare/@discordjs/rest@2.0.1...@discordjs/rest@2.1.0)

#### Bug Fixes

-   **REST:** Strip webhook tokens ([#&#8203;9723](discordjs/discord.js#9723)) ([cf49f40](discordjs/discord.js@cf49f40))

#### Documentation

-   Fix "its" typo ([#&#8203;9825](discordjs/discord.js#9825)) ([c50809e](discordjs/discord.js@c50809e))
-   **create-discord-bot:** Support bun in create-discord-bot ([#&#8203;9798](discordjs/discord.js#9798)) ([7157748](discordjs/discord.js@7157748))

#### Features

-   Expose Retry-After and sublimit timeouts in RatelimitData ([#&#8203;9864](discordjs/discord.js#9864)) ([81e7866](discordjs/discord.js@81e7866))
-   **CDN:** Support emoji size ([#&#8203;9787](discordjs/discord.js#9787)) ([778df45](discordjs/discord.js@778df45))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/375
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
4 participants