davexbaileys 2.5.12 → 2.5.13
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/Socket/socket.js +2 -1
- package/lib/Utils/generics.js +7 -5
- package/package.json +1 -1
package/lib/Socket/socket.js
CHANGED
|
@@ -555,7 +555,8 @@ export const makeSocket = (config) => {
|
|
|
555
555
|
check if it's been a suspicious amount of time since the server responded with our last seen
|
|
556
556
|
it could be that the network is down
|
|
557
557
|
*/
|
|
558
|
-
if (diff > keepAliveIntervalMs
|
|
558
|
+
if (diff > keepAliveIntervalMs * 3) {
|
|
559
|
+
// 3x interval grace period — avoids false 408 on slow cloud platforms (Heroku, Railway etc)
|
|
559
560
|
end(new Boom('Connection was lost', { statusCode: DisconnectReason.connectionLost }));
|
|
560
561
|
}
|
|
561
562
|
else if (ws.isOpen) {
|
package/lib/Utils/generics.js
CHANGED
|
@@ -303,13 +303,15 @@ export const getCodeFromWSError = (error) => {
|
|
|
303
303
|
statusCode = code;
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
|
-
else if (
|
|
307
|
-
|
|
308
|
-
error?.code?.startsWith('E') ||
|
|
309
|
-
error?.message?.includes('timed out')) {
|
|
310
|
-
// handle ETIMEOUT, ENOTFOUND etc
|
|
306
|
+
else if (error?.message?.includes('timed out') || error?.code === 'ETIMEDOUT') {
|
|
307
|
+
// genuine timeout — map to connectionLost (408) for retry
|
|
311
308
|
statusCode = 408;
|
|
312
309
|
}
|
|
310
|
+
else if (error?.code?.startsWith('E')) {
|
|
311
|
+
// network reset/unavailable (ECONNRESET, ENOTFOUND etc) — NOT a 408 timeout loop
|
|
312
|
+
// use 503 so bots can distinguish and apply a smarter reconnect strategy
|
|
313
|
+
statusCode = 503;
|
|
314
|
+
}
|
|
313
315
|
return statusCode;
|
|
314
316
|
};
|
|
315
317
|
/**
|