coffeeinabit 0.0.56 → 0.0.58
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/linkedin_automation.js
CHANGED
|
@@ -40,6 +40,7 @@ export class LinkedInAutomation {
|
|
|
40
40
|
this.screenshotIntervalMs = 3000;
|
|
41
41
|
this.actionPollingIntervalMs = 15000;
|
|
42
42
|
this.currentAction = null;
|
|
43
|
+
this.currentActionStartedAt = null;
|
|
43
44
|
this.userEmail = null;
|
|
44
45
|
this.isActionPollingActive = false;
|
|
45
46
|
this.linkedInSessionDir = getContextDirectory();
|
|
@@ -48,6 +49,9 @@ export class LinkedInAutomation {
|
|
|
48
49
|
this._currentRefreshToken = null;
|
|
49
50
|
this._currentAccessToken = null; // Track access token explicitly
|
|
50
51
|
|
|
52
|
+
// Action execution timeout (5 minutes)
|
|
53
|
+
this.actionTimeoutMs = 5 * 60 * 1000;
|
|
54
|
+
|
|
51
55
|
// Authentication failure tracking
|
|
52
56
|
this.consecutiveAuthFailures = 0;
|
|
53
57
|
this.maxAuthFailures = 3; // Stop polling after 3 consecutive failures
|
|
@@ -751,10 +755,18 @@ export class LinkedInAutomation {
|
|
|
751
755
|
}
|
|
752
756
|
|
|
753
757
|
if (this.currentAction) {
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
+
const elapsed = Date.now() - (this.currentActionStartedAt || Date.now());
|
|
759
|
+
if (elapsed > this.actionTimeoutMs) {
|
|
760
|
+
logger.error(`[LinkedInAutomation] Action ${this.currentAction.action} timed out after ${Math.round(elapsed / 1000)}s, force-clearing`);
|
|
761
|
+
this.currentAction = null;
|
|
762
|
+
this.currentActionStartedAt = null;
|
|
763
|
+
this.emitActionUpdate();
|
|
764
|
+
} else {
|
|
765
|
+
logger.log(`[LinkedInAutomation] Action in progress (${Math.round(elapsed / 1000)}s), skipping polling...`);
|
|
766
|
+
logger.log('[LinkedInAutomation] Next poll in', Math.round(currentInterval / 1000), 'seconds');
|
|
767
|
+
setTimeout(pollWithBackoff, currentInterval);
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
758
770
|
}
|
|
759
771
|
|
|
760
772
|
// pollForActions now returns true if actions were found and processed
|
|
@@ -1002,13 +1014,14 @@ export class LinkedInAutomation {
|
|
|
1002
1014
|
await closeAllConversationBubbles(this.page);
|
|
1003
1015
|
|
|
1004
1016
|
try {
|
|
1005
|
-
logger.log('[LinkedInAutomation] Starting execution of action:', action.action, 'ID:', action.action_id);
|
|
1017
|
+
logger.log('[LinkedInAutomation] Starting execution of action:', action.action, 'ID:', action.action_id, 'Local time:', new Date().toLocaleString());
|
|
1006
1018
|
logger.log('[LinkedInAutomation] Action parameters:', JSON.stringify(action.parameters, null, 2));
|
|
1007
1019
|
this.currentAction = action;
|
|
1020
|
+
this.currentActionStartedAt = Date.now();
|
|
1008
1021
|
this.status = 'executing_action';
|
|
1009
1022
|
this.emitActionUpdate();
|
|
1010
1023
|
this.emitStatus();
|
|
1011
|
-
|
|
1024
|
+
|
|
1012
1025
|
let result = null;
|
|
1013
1026
|
|
|
1014
1027
|
// Normalize: if no username in parameters, use linkedin_profile_id from action
|
|
@@ -1111,6 +1124,7 @@ export class LinkedInAutomation {
|
|
|
1111
1124
|
console.warn = originalConsoleWarn;
|
|
1112
1125
|
|
|
1113
1126
|
this.currentAction = null;
|
|
1127
|
+
this.currentActionStartedAt = null;
|
|
1114
1128
|
this.emitActionUpdate();
|
|
1115
1129
|
}
|
|
1116
1130
|
}
|
package/package.json
CHANGED
package/routes/automation.js
CHANGED
|
@@ -25,7 +25,7 @@ export function createAutomationRoutes(cloudAuth, appState, linkedinAutomation,
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
try {
|
|
28
|
-
const { headless =
|
|
28
|
+
const { headless = true, socketId = null } = req.body;
|
|
29
29
|
|
|
30
30
|
// If socketId provided, use process-specific automation
|
|
31
31
|
// Otherwise, use legacy single instance (for backward compatibility)
|
|
@@ -348,10 +348,11 @@ export async function executeGetMessageThreads(page, action) {
|
|
|
348
348
|
let cutoffTimestamp;
|
|
349
349
|
const param = action.parameters?.last_updated_timestamp;
|
|
350
350
|
if (param) {
|
|
351
|
-
cutoffTimestamp =
|
|
351
|
+
cutoffTimestamp = parseInt(param, 10);
|
|
352
352
|
} else {
|
|
353
353
|
cutoffTimestamp = Date.now() - (14 * 24 * 60 * 60 * 1000);
|
|
354
354
|
}
|
|
355
|
+
console.log(`[GetMessageThreads] Cutoff timestamp: ${cutoffTimestamp} (${new Date(cutoffTimestamp).toLocaleString()})`);
|
|
355
356
|
|
|
356
357
|
const threadsMap = new Map();
|
|
357
358
|
const processedMessageKeys = new Set();
|