Skip to content

Commit cac7f38

Browse files
authored
Add throttling, retries when rate-limited, improve performance (#2158)
1 parent 1accb3b commit cac7f38

File tree

12,677 files changed

+131922
-4110746
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

12,677 files changed

+131922
-4110746
lines changed

.coderabbit.yaml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
language: en-US
2+
tone_instructions: ''
3+
early_access: true
4+
enable_free_tier: true
5+
reviews:
6+
profile: chill
7+
request_changes_workflow: false
8+
high_level_summary: false
9+
high_level_summary_placeholder: '@coderabbitai summary'
10+
high_level_summary_in_walkthrough: true
11+
auto_title_placeholder: '@coderabbitai'
12+
auto_title_instructions: ''
13+
review_status: true
14+
commit_status: true
15+
fail_commit_status: false
16+
collapse_walkthrough: true
17+
changed_files_summary: true
18+
sequence_diagrams: false
19+
assess_linked_issues: true
20+
related_issues: true
21+
related_prs: true
22+
suggested_labels: false
23+
auto_apply_labels: false
24+
suggested_reviewers: false
25+
poem: false
26+
labeling_instructions: []
27+
path_filters:
28+
- "!dist/**"
29+
- "!tests/**"
30+
path_instructions: []
31+
abort_on_close: true
32+
auto_review:
33+
enabled: true
34+
auto_incremental_review: true
35+
ignore_title_keywords: []
36+
labels: []
37+
drafts: false
38+
base_branches: []
39+
finishing_touches:
40+
docstrings:
41+
enabled: false
42+
tools:
43+
shellcheck:
44+
enabled: true
45+
ruff: # for Python
46+
enabled: false
47+
markdownlint:
48+
enabled: true
49+
github-checks:
50+
enabled: true
51+
timeout_ms: 90000
52+
languagetool:
53+
enabled: true
54+
enabled_only: false
55+
level: default
56+
biome: # For JavaScript/TypeScript
57+
enabled: false
58+
hadolint:
59+
enabled: true
60+
swiftlint: # For Swift
61+
enabled: false
62+
phpstan: # For PHP
63+
enabled: false
64+
level: default
65+
golangci-lint: # For Go
66+
enabled: false
67+
yamllint:
68+
enabled: true
69+
gitleaks:
70+
enabled: true
71+
checkov:
72+
enabled: true
73+
detekt: # For Kotlin
74+
enabled: false
75+
eslint: # For JavaScript/TypeScript
76+
enabled: true
77+
rubocop: # For Ruby
78+
enabled: false
79+
buf: # For Protobuf
80+
enabled: false
81+
regal: # For Rego
82+
enabled: false
83+
actionlint:
84+
enabled: true
85+
pmd: # For Java
86+
enabled: false
87+
cppcheck: # For C/C++
88+
enabled: false
89+
semgrep: # Static analysis. CodeRabbit recommends disabling this tool unless you configure specific rules for it.
90+
enabled: false
91+
circleci: # For CircleCI
92+
enabled: false
93+
chat:
94+
auto_reply: true
95+
integrations:
96+
jira:
97+
usage: disabled
98+
linear:
99+
usage: disabled
100+
knowledge_base:
101+
opt_out: false
102+
learnings:
103+
scope: auto
104+
issues:
105+
scope: auto
106+
jira:
107+
usage: disabled
108+
project_keys: []
109+
linear:
110+
usage: disabled
111+
team_keys: []
112+
pull_requests:
113+
scope: auto

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ $RECYCLE.BIN/
1717
/coverage
1818
.build-harness
1919
build-harness
20+
21+
# Local development files
22+
/node_modules/

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.19.0

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,12 @@ export README_DEPS ?= docs/github-action.md
77

88
## Lint terraform code
99
lint:
10-
$(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate
10+
$(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate
11+
12+
## Build the project using vercel/ncc
13+
build:
14+
@echo "Building the project..."
15+
@PATH="$(PATH):./node_modules/.bin" ncc build src/index.js -o dist
16+
@echo "Commit changes to dist/"
17+
@git add dist/ || true
18+
@git diff --cached --quiet dist/ || git commit -m "Update dist/ after build" || true

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ inputs:
3434

3535
runs:
3636
using: 'node20'
37-
main: 'src/index.js'
37+
main: 'dist/index.js'

dist/992.index.js

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
"use strict";
2+
exports.id = 992;
3+
exports.ids = [992];
4+
exports.modules = {
5+
6+
/***/ 65992:
7+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8+
9+
__webpack_require__.r(__webpack_exports__);
10+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
11+
/* harmony export */ "default": () => (/* binding */ pThrottle)
12+
/* harmony export */ });
13+
const registry = new FinalizationRegistry(({signal, aborted}) => {
14+
signal?.removeEventListener('abort', aborted);
15+
});
16+
17+
function pThrottle({limit, interval, strict, signal, onDelay}) {
18+
if (!Number.isFinite(limit)) {
19+
throw new TypeError('Expected `limit` to be a finite number');
20+
}
21+
22+
if (!Number.isFinite(interval)) {
23+
throw new TypeError('Expected `interval` to be a finite number');
24+
}
25+
26+
const queue = new Map();
27+
28+
let currentTick = 0;
29+
let activeCount = 0;
30+
31+
function windowedDelay() {
32+
const now = Date.now();
33+
34+
if ((now - currentTick) > interval) {
35+
activeCount = 1;
36+
currentTick = now;
37+
return 0;
38+
}
39+
40+
if (activeCount < limit) {
41+
activeCount++;
42+
} else {
43+
currentTick += interval;
44+
activeCount = 1;
45+
}
46+
47+
return currentTick - now;
48+
}
49+
50+
const strictTicks = [];
51+
52+
function strictDelay() {
53+
const now = Date.now();
54+
55+
// Clear the queue if there's a significant delay since the last execution
56+
if (strictTicks.length > 0 && now - strictTicks.at(-1) > interval) {
57+
strictTicks.length = 0;
58+
}
59+
60+
// If the queue is not full, add the current time and execute immediately
61+
if (strictTicks.length < limit) {
62+
strictTicks.push(now);
63+
return 0;
64+
}
65+
66+
// Calculate the next execution time based on the first item in the queue
67+
const nextExecutionTime = strictTicks[0] + interval;
68+
69+
// Shift the queue and add the new execution time
70+
strictTicks.shift();
71+
strictTicks.push(nextExecutionTime);
72+
73+
// Calculate the delay for the current execution
74+
return Math.max(0, nextExecutionTime - now);
75+
}
76+
77+
const getDelay = strict ? strictDelay : windowedDelay;
78+
79+
return function_ => {
80+
const throttled = function (...arguments_) {
81+
if (!throttled.isEnabled) {
82+
return (async () => function_.apply(this, arguments_))();
83+
}
84+
85+
let timeoutId;
86+
return new Promise((resolve, reject) => {
87+
const execute = () => {
88+
resolve(function_.apply(this, arguments_));
89+
queue.delete(timeoutId);
90+
};
91+
92+
const delay = getDelay();
93+
if (delay > 0) {
94+
timeoutId = setTimeout(execute, delay);
95+
queue.set(timeoutId, reject);
96+
onDelay?.(...arguments_);
97+
} else {
98+
execute();
99+
}
100+
});
101+
};
102+
103+
const aborted = () => {
104+
for (const timeout of queue.keys()) {
105+
clearTimeout(timeout);
106+
queue.get(timeout)(signal.reason);
107+
}
108+
109+
queue.clear();
110+
strictTicks.splice(0, strictTicks.length);
111+
};
112+
113+
registry.register(throttled, {signal, aborted});
114+
115+
signal?.throwIfAborted();
116+
signal?.addEventListener('abort', aborted, {once: true});
117+
118+
throttled.isEnabled = true;
119+
120+
Object.defineProperty(throttled, 'queueSize', {
121+
get() {
122+
return queue.size;
123+
},
124+
});
125+
126+
return throttled;
127+
};
128+
}
129+
130+
131+
/***/ })
132+
133+
};
134+
;

dist/assets/comment-no-changes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
> [!IMPORTANT]
2+
> **No Changes Were Applied**
3+
>
4+
> This Pull Request was merged without using the `auto-apply` label; in any case, the pull request did not contain any changes to apply.

dist/assets/comment.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
> [!IMPORTANT]
2+
> **No Changes Were Applied**
3+
>
4+
> This Pull Request was merged without using the `auto-apply` label; therefore, no changes were applied upon merging.
5+
6+
Review the associated issues and, if applicable, tag each with the `apply` label to apply the changes.

dist/assets/summary-no-changes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
> [!IMPORTANT]
2+
> **No Changes Were Applied**
3+
>
4+
> This Pull Request was merged without using the \`auto-apply\` label; in any case, the pull request did not contain any changes to apply.

dist/comment-no-changes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
> [!IMPORTANT]
2+
> **No Changes Were Applied**
3+
>
4+
> This Pull Request was merged without using the `auto-apply` label; in any case, the pull request did not contain any changes to apply.

0 commit comments

Comments
 (0)