Skip to content

Commit bd535a6

Browse files
committed
Add simple rate limiting
1 parent 4d98754 commit bd535a6

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/plugin.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ export default class ArtimiPlugin {
6969
})
7070

7171
if (!res.ok) {
72+
if (res.status === 429) {
73+
logger.warn('Rate limited! Pausing for 30s...')
74+
await new Promise(resolve => {
75+
setTimeout(30_000, null, {
76+
signal: this.controller.signal
77+
}).then(resolve, resolve)
78+
})
79+
continue
80+
}
7281
throw new Error(await res.text())
7382
}
7483

@@ -144,7 +153,7 @@ export default class ArtimiPlugin {
144153
}
145154

146155
ArtimiPlugin.defaults = {
147-
htr: true,
156+
htr: false,
148157
model: null,
149158
token: null,
150159
interval: 10_000,

0 commit comments

Comments
 (0)