-
Notifications
You must be signed in to change notification settings - Fork 10
fix(application): recover addon runtime during launch #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| export class RendererEventReadiness { | ||
| private ready = false; | ||
| private readonly waiters = new Set<() => void>(); | ||
|
|
||
| public isReady(): boolean { | ||
| return this.ready; | ||
| } | ||
|
|
||
| public markReady(): void { | ||
| this.ready = true; | ||
| for (const waiter of this.waiters) waiter(); | ||
| this.waiters.clear(); | ||
| } | ||
|
|
||
| public reset(): void { | ||
| this.ready = false; | ||
| } | ||
|
|
||
| public wait(timeoutMs: number, onTimeout: () => void): Promise<void> { | ||
| if (this.ready) return Promise.resolve(); | ||
|
|
||
| return new Promise((resolve) => { | ||
| const finish = (): void => { | ||
| clearTimeout(timeout); | ||
| this.waiters.delete(finish); | ||
| resolve(); | ||
| }; | ||
| const timeout = setTimeout(() => { | ||
| this.waiters.delete(finish); | ||
| onTimeout(); | ||
| resolve(); | ||
| }, timeoutMs); | ||
| this.waiters.add(finish); | ||
| }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -47,14 +47,13 @@ import { | |||||||
| viewOpenedWhenChanged, | ||||||||
| } from '@/frontend/store.svelte'; | ||||||||
| import { | ||||||||
| addonServer, | ||||||||
| fetchAddonsWithConfigure, | ||||||||
| getAddonServerPromise, | ||||||||
| getConfigClientOption, | ||||||||
| initDownloadPersistence, | ||||||||
| initSleepLock, | ||||||||
| isAddonEventAvailable, | ||||||||
| queryConnectedAddons, | ||||||||
| reconnectClientSdk, | ||||||||
| } from '@/frontend/utils'; | ||||||||
| import ClientOptionsView from '@/frontend/views/ClientOptionsView.svelte'; | ||||||||
| import ConfigView from '@/frontend/views/ConfigView.svelte'; | ||||||||
|
|
@@ -232,6 +231,7 @@ async function performSearch(query: string) { | |||||||
| emptyAddons = new Set(); | ||||||||
|
|
||||||||
| // Search through addons and organize results by addon | ||||||||
| const addonServer = await getAddonServerPromise(); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win Recheck cancellation after connection acquisition.
Proposed fix const addonServer = await getAddonServerPromise();
+ if (signal.aborted || query !== activeQuery) return;
let promises: Promise<void>[] = [];📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| let promises: Promise<void>[] = []; | ||||||||
| for (const addon of searchAddons) { | ||||||||
| promises.push( | ||||||||
|
|
@@ -419,25 +419,6 @@ document.addEventListener('all-addons-started', async () => { | |||||||
| type: 'success', | ||||||||
| }); | ||||||||
| addonUpdates.set([]); | ||||||||
| // restart the addon server | ||||||||
| await runFrontendEffect(electronRpc.restartAddonServer()); | ||||||||
| await runFrontendEffect( | ||||||||
| reconnectClientSdk().pipe( | ||||||||
| Effect.catchAll((error) => | ||||||||
| Effect.sync(() => { | ||||||||
| logger.sync.error( | ||||||||
| 'Failed to reconnect to the addon server:', | ||||||||
| error | ||||||||
| ); | ||||||||
| createNotification({ | ||||||||
| id: Math.random().toString(36).substring(7), | ||||||||
| message: 'Failed to reconnect to the addon server', | ||||||||
| type: 'error', | ||||||||
| }); | ||||||||
| }) | ||||||||
| ) | ||||||||
| ) | ||||||||
| ); | ||||||||
| } | ||||||||
| }); | ||||||||
| document.addEventListener('addon:updated', (event) => { | ||||||||
|
|
@@ -449,14 +430,6 @@ document.addEventListener('addon:updated', (event) => { | |||||||
| }); | ||||||||
| } | ||||||||
| }); | ||||||||
| document.addEventListener('addon-connected', (event) => { | ||||||||
| if (event instanceof CustomEvent) { | ||||||||
| runDetached( | ||||||||
| fetchAddonsWithConfigure().pipe(Effect.asVoid), | ||||||||
| 'Failed to refresh addons' | ||||||||
| ); | ||||||||
| } | ||||||||
| }); | ||||||||
| currentStorePageOpened.subscribe((value) => { | ||||||||
| if (value) { | ||||||||
| heldPageOpened = value; | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Nat3z/OpenGameInstaller
Length of output: 2861
🏁 Script executed:
Repository: Nat3z/OpenGameInstaller
Length of output: 16507
🌐 Web query:
Electron webContents did-start-navigation same document navigation isInPlace documentation💡 Result:
In modern Electron versions, the isInPlace property within the did-start-navigation event is deprecated [1][2]. It has been replaced by the isSameDocument property, which is provided as part of the details object [1][2]. The isSameDocument property is a boolean that indicates whether the navigation occurs within the same document [1][2]. Navigations considered to be in the same document include: - Reference fragment (hash) changes [1][2]. - Use of the History API (pushState/replaceState) [1][2]. - Same-page history navigation [1][2]. Developers are encouraged to use the isSameDocument property instead of the deprecated isInPlace, which was used in older versions of Electron to identify "in-page" navigations [3][4][5]. If you are working with type definitions, ensure you are accessing this information through the details object rather than relying on the legacy event parameters [6].
Citations:
🏁 Script executed:
Repository: Nat3z/OpenGameInstaller
Length of output: 5315
Reset readiness only for new-document navigation.
did-start-navigationalso fires for same-document navigation. The renderer sendsclient-ready-for-eventsonly during initialization. Gatereset()on the navigation's same-document flag and add regression coverage for History API and fragment navigation.🤖 Prompt for AI Agents