app-manager-edge-worker 1.1.1 → 1.1.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "app-manager-edge-worker",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Distributed Scraper Edge Worker for Apps Manager. Run on any local machine, VPS, or Termux Android device to serve browser and HTTP scraping jobs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -158,6 +158,10 @@ export class WhatsAppWorkerHandler {
|
|
|
158
158
|
syncFullHistory: false,
|
|
159
159
|
markOnlineOnConnect: false, // Stealth Presence: Does NOT broadcast green online dot
|
|
160
160
|
generateHighQualityLinkPreview: true,
|
|
161
|
+
defaultQueryTimeoutMs: 60000,
|
|
162
|
+
connectTimeoutMs: 60000,
|
|
163
|
+
keepAliveIntervalMs: 25000,
|
|
164
|
+
getMessage: async () => undefined,
|
|
161
165
|
};
|
|
162
166
|
if (version) socketConfig.version = version;
|
|
163
167
|
|
|
@@ -212,6 +216,8 @@ export class WhatsAppWorkerHandler {
|
|
|
212
216
|
|
|
213
217
|
this._resetIdleTimer();
|
|
214
218
|
|
|
219
|
+
console.log(`[WhatsApp Worker] Companion Device paired successfully! User: ${this.user.name || "WhatsApp User"} (+${this.user.phone})`);
|
|
220
|
+
|
|
215
221
|
this.onStatusChange({
|
|
216
222
|
status: "CONNECTED",
|
|
217
223
|
phone: this.user.phone,
|
|
@@ -222,12 +228,15 @@ export class WhatsAppWorkerHandler {
|
|
|
222
228
|
|
|
223
229
|
if (connection === "close") {
|
|
224
230
|
this.isInitializing = false;
|
|
225
|
-
const
|
|
231
|
+
const error = lastDisconnect?.error;
|
|
232
|
+
const statusCode = error?.output?.statusCode;
|
|
226
233
|
const isLoggedOut =
|
|
227
234
|
statusCode === DisconnectReason.loggedOut ||
|
|
228
235
|
statusCode === 401 ||
|
|
229
236
|
statusCode === DisconnectReason.badSession;
|
|
230
237
|
|
|
238
|
+
console.log(`[WhatsApp Worker] Connection closed. StatusCode: ${statusCode}. LoggedOut: ${isLoggedOut}`);
|
|
239
|
+
|
|
231
240
|
if (isLoggedOut) {
|
|
232
241
|
// Mobile App or Meta unlinked this companion device
|
|
233
242
|
this.status = "DISCONNECTED";
|
|
@@ -247,8 +256,21 @@ export class WhatsAppWorkerHandler {
|
|
|
247
256
|
reason: "LOGGED_OUT_BY_PHONE",
|
|
248
257
|
});
|
|
249
258
|
} else {
|
|
250
|
-
//
|
|
251
|
-
|
|
259
|
+
// Post-scan restart (code 515 restartRequired) or temporary network glitch:
|
|
260
|
+
// WhatsApp protocol REQUIRES immediate socket reconnection to finalize the multi-device key exchange!
|
|
261
|
+
if (this.sock) {
|
|
262
|
+
try {
|
|
263
|
+
this.sock.end(undefined);
|
|
264
|
+
} catch (_) {}
|
|
265
|
+
this.sock = null;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
console.log("[WhatsApp Worker] Reconnecting to finalize credentials and establish active session...");
|
|
269
|
+
setTimeout(() => {
|
|
270
|
+
this.initialize(false).catch((err) => {
|
|
271
|
+
console.error("[WhatsApp Worker] Reconnection error:", err.message);
|
|
272
|
+
});
|
|
273
|
+
}, 1000);
|
|
252
274
|
}
|
|
253
275
|
}
|
|
254
276
|
});
|