Skip to content

Commit 27bdd26

Browse files
committed
attempt to fix gcp issue
1 parent 4576a08 commit 27bdd26

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

app/src/electron/services/PythonServerService.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class PythonServerService {
2727
private isServerRunning = false;
2828
private isIndexingComplete = false;
2929
private isPackaged: boolean;
30+
private isInitializing = false;
3031

3132
constructor(config: Partial<PythonServerConfig> = {}) {
3233
console.log('[PythonServerService] DEBUG: Constructor called with config:', JSON.stringify(config, null, 2));
@@ -189,6 +190,19 @@ export class PythonServerService {
189190

190191
async initialize(): Promise<void> {
191192
console.log('[PythonServerService] DEBUG: Initialize called');
193+
194+
// Prevent multiple simultaneous initialization attempts
195+
if (this.isInitializing) {
196+
console.log('[PythonServerService] Initialization already in progress, skipping...');
197+
return;
198+
}
199+
200+
if (this.isServerRunning) {
201+
console.log('[PythonServerService] Server already running, skipping initialization...');
202+
return;
203+
}
204+
205+
this.isInitializing = true;
192206
console.log('[PythonServerService] Initializing Python server service...');
193207

194208
try {
@@ -230,6 +244,8 @@ export class PythonServerService {
230244
console.error('[PythonServerService] ERROR: Failed to initialize:', error);
231245
console.error('[PythonServerService] ERROR: Stack trace:', error instanceof Error ? error.stack : 'No stack trace');
232246
throw error;
247+
} finally {
248+
this.isInitializing = false;
233249
}
234250
}
235251

@@ -590,6 +606,10 @@ export class PythonServerService {
590606
const isSSLWarning = output.includes('NotOpenSSLWarning') || output.includes('urllib3') || output.includes('LibreSSL');
591607
const isVectorStoreWarning = output.includes('Vector store directory not found') ||
592608
output.includes('Make sure to run the indexing script');
609+
const isGoogleCloudWarning = output.includes('ALTS creds ignored') ||
610+
output.includes('absl::InitializeLog') ||
611+
output.includes('Not running on GCP') ||
612+
output.includes('All log messages before absl::InitializeLog');
593613

594614
if (isAccessLog || isFlaskStartupInfo) {
595615
// This is normal Flask logging, log as info
@@ -600,14 +620,17 @@ export class PythonServerService {
600620
} else if (isVectorStoreWarning) {
601621
// Vector store warnings are expected if indexing failed - log as warning
602622
console.warn('[PythonServerService] FLASK VECTOR WARNING:', output.trim());
623+
} else if (isGoogleCloudWarning) {
624+
// Google Cloud warnings are not critical - just log as warning
625+
console.warn('[PythonServerService] FLASK GCP WARNING:', output.trim());
603626
} else {
604627
// This is likely an actual error
605628
console.error('[PythonServerService] FLASK ERROR:', output.trim());
606629
}
607630

608631
if (!serverStarted) {
609-
// Only treat as startup error if it's not a normal log, SSL warning, or vector store warning
610-
if (!isAccessLog && !isFlaskStartupInfo && !isSSLWarning && !isVectorStoreWarning) {
632+
// Only treat as startup error if it's not a normal log, SSL warning, vector store warning, or Google Cloud warning
633+
if (!isAccessLog && !isFlaskStartupInfo && !isSSLWarning && !isVectorStoreWarning && !isGoogleCloudWarning) {
611634
cleanup();
612635
reject(new Error(`Flask server failed to start: ${output}`));
613636
}

0 commit comments

Comments
 (0)