| 432 | } |
| 433 | |
| 434 | private async awaitWithDevTimeout<T>(promise: Promise<T>, name: string, tabId: string): Promise<T> { |
| 435 | if (!isDev) { |
| 436 | return promise; |
| 437 | } |
| 438 | let timeoutHandle: ReturnType<typeof setTimeout> = null; |
| 439 | const timeoutPromise = new Promise<never>((_, reject) => { |
| 440 | timeoutHandle = setTimeout(() => { |
| 441 | console.log( |
| 442 | `[dev] ${name} timed out after ${DevInitTimeoutMs}ms for tab ${tabId}, showing window for devtools` |
| 443 | ); |
| 444 | if (!this.isDestroyed() && !this.isVisible()) { |
| 445 | this.show(); |
| 446 | } |
| 447 | if (this.activeTabView?.webContents && !this.activeTabView.webContents.isDevToolsOpened()) { |
| 448 | this.activeTabView.webContents.openDevTools(); |
| 449 | } |
| 450 | reject(new Error(`[dev] ${name} timed out after ${DevInitTimeoutMs}ms`)); |
| 451 | }, DevInitTimeoutMs); |
| 452 | }); |
| 453 | try { |
| 454 | return await Promise.race([promise, timeoutPromise]); |
| 455 | } finally { |
| 456 | clearTimeout(timeoutHandle); |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | private async setTabViewIntoWindow(tabView: WaveTabView, tabInitialized: boolean, primaryStartupTab = false) { |
| 461 | if (this.activeTabView == tabView) { |