moltedopus 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/heartbeat.js +8 -7
- package/package.json +1 -1
package/lib/heartbeat.js
CHANGED
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
* Restart hint → stdout as: RESTART:moltedopus [flags]
|
|
56
56
|
*/
|
|
57
57
|
|
|
58
|
-
const VERSION = '1.5.
|
|
58
|
+
const VERSION = '1.5.2';
|
|
59
59
|
|
|
60
60
|
// ============================================================
|
|
61
61
|
// IMPORTS (zero dependencies — Node.js built-ins only)
|
|
@@ -200,11 +200,12 @@ async function api(method, endpoint, body = null) {
|
|
|
200
200
|
try { data = JSON.parse(text); } catch { data = { raw: text }; }
|
|
201
201
|
|
|
202
202
|
if (res.status === 429) {
|
|
203
|
-
const wait = data.retry_after ||
|
|
203
|
+
const wait = data.retry_after || 5;
|
|
204
204
|
const recInterval = data.recommended_interval || 0;
|
|
205
205
|
log(`RATE LIMITED: ${data.message || data.error || 'Too fast'}. Waiting ${wait}s...`);
|
|
206
206
|
await sleep(wait * 1000);
|
|
207
|
-
|
|
207
|
+
// Return recommended interval — caller should ADOPT it (not just increase)
|
|
208
|
+
return { _rate_limited: true, _recommended_interval: recInterval, _already_waited: true };
|
|
208
209
|
}
|
|
209
210
|
if (res.status === 401) {
|
|
210
211
|
log(`AUTH ERROR: ${data.error || 'Invalid or expired token'}`);
|
|
@@ -2105,12 +2106,12 @@ async function heartbeatLoop(args, savedConfig) {
|
|
|
2105
2106
|
continue;
|
|
2106
2107
|
}
|
|
2107
2108
|
if (data._rate_limited) {
|
|
2108
|
-
//
|
|
2109
|
-
if (data._recommended_interval && data._recommended_interval
|
|
2109
|
+
// ALWAYS adopt server-recommended interval (fix: don't only increase, also decrease)
|
|
2110
|
+
if (data._recommended_interval && data._recommended_interval > 0) {
|
|
2110
2111
|
interval = data._recommended_interval * 1000;
|
|
2111
2112
|
}
|
|
2112
|
-
//
|
|
2113
|
-
|
|
2113
|
+
// Already waited retry_after in api() — just continue to next cycle
|
|
2114
|
+
// (the normal sleep at bottom of loop handles the interval)
|
|
2114
2115
|
continue;
|
|
2115
2116
|
}
|
|
2116
2117
|
retries = 0;
|