You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/background/index.mjs
+39-18Lines changed: 39 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -319,17 +319,39 @@ async function executeApi(session, port, config) {
319
319
try{
320
320
port.proxy.postMessage({ session })
321
321
}catch(e){
322
-
console.error('[background] Error posting message to proxy tab in executeApi (ChatGPT Web Model):',e,{ session });
323
-
try{
324
-
port.postMessage({error: 'Failed to communicate with ChatGPT tab. Try refreshing the page.'});
325
-
}catch(notifyError){
326
-
console.error('[background] Error sending communication failure notification back:',notifyError);
322
+
console.warn('[background] Error posting message to existing proxy tab in executeApi (ChatGPT Web Model):',e,'. Attempting to reconnect.',{ session });
323
+
setPortProxy(port,tabId);// Attempt to re-establish the connection
324
+
if(port.proxy){
325
+
console.debug('[background] Proxy re-established. Attempting to post message again.');
326
+
try{
327
+
port.proxy.postMessage({ session });
328
+
console.info('[background] Successfully posted session after proxy reconnection.');
329
+
}catch(e2){
330
+
console.error('[background] Error posting message even after proxy reconnection:',e2,{ session });
331
+
try{
332
+
port.postMessage({error: 'Failed to communicate with ChatGPT tab after reconnection attempt. Try refreshing the page.'});
333
+
}catch(notifyError){
334
+
console.error('[background] Error sending final communication failure notification back:',notifyError);
335
+
}
336
+
}
337
+
}else{
338
+
console.error('[background] Failed to re-establish proxy connection. Cannot send session.');
339
+
try{
340
+
port.postMessage({error: 'Could not re-establish connection to ChatGPT tab. Try refreshing the page.'});
0 commit comments