-
Notifications
You must be signed in to change notification settings - Fork 9
feat: Separated Addon Server To A Separate Package #126
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
f56a89f
35414cc
162457b
b7c6b4f
98260f5
0541ada
b2c1b62
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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,19 +1,19 @@ | ||||||||||||||||||
| import axios from 'axios'; | ||||||||||||||||||
| import { ipcMain, app } from 'electron'; | ||||||||||||||||||
| import { currentScreens } from '@/electron/main.js'; | ||||||||||||||||||
| import { currentScreens, screenInputCallbacks } from '@/electron/main.js'; | ||||||||||||||||||
| import * as fs from 'fs'; | ||||||||||||||||||
| import { join } from 'path'; | ||||||||||||||||||
| import * as os from 'os'; | ||||||||||||||||||
| import * as path from 'path'; | ||||||||||||||||||
| import { createReadStream, createWriteStream } from 'fs'; | ||||||||||||||||||
| import { isDev } from '@/electron/manager/manager.paths.js'; | ||||||||||||||||||
| import { __dirname } from '@/electron/manager/manager.paths.js'; | ||||||||||||||||||
| import { clients } from '@/electron/server/addon-server.js'; | ||||||||||||||||||
| import { registerSteamHandlers } from '@/electron/handlers/handler.steam.js'; | ||||||||||||||||||
| import { registerLibraryHandlers } from '@/electron/handlers/handler.library.js'; | ||||||||||||||||||
| import { registerRedistributableHandlers } from '@/electron/handlers/handler.redists.js'; | ||||||||||||||||||
| import { getCurrentUsername } from './helpers.app/platform.js'; | ||||||||||||||||||
| import { getEffectiveOnlineState } from '@/electron/lib/online.js'; | ||||||||||||||||||
| import { addonServer } from '@/electron/server/addon-server.js'; | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Escapes a string for safe use in shell commands by escaping special characters | ||||||||||||||||||
|
|
@@ -189,6 +189,11 @@ export default function handler(mainWindow: Electron.BrowserWindow) { | |||||||||||||||||
| }); | ||||||||||||||||||
| ipcMain.handle('app:screen-input', async (_, data) => { | ||||||||||||||||||
| currentScreens.set(data.id, data.data); | ||||||||||||||||||
| const callback = screenInputCallbacks.get(data.id); | ||||||||||||||||||
| if (callback) { | ||||||||||||||||||
| callback(data.data); | ||||||||||||||||||
| screenInputCallbacks.delete(data.id); | ||||||||||||||||||
|
Comment on lines
+192
to
+195
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. Always clear one-shot screen callbacks even if they throw. If Suggested fix const callback = screenInputCallbacks.get(data.id);
if (callback) {
- callback(data.data);
- screenInputCallbacks.delete(data.id);
+ screenInputCallbacks.delete(data.id);
+ callback(data.data);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| } | ||||||||||||||||||
| return; | ||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -198,14 +203,14 @@ export default function handler(mainWindow: Electron.BrowserWindow) { | |||||||||||||||||
|
|
||||||||||||||||||
| // Addon helpers | ||||||||||||||||||
| ipcMain.handle('app:get-addon-path', async (_, addonID: string) => { | ||||||||||||||||||
| let client = clients.get(addonID); | ||||||||||||||||||
| let client = addonServer.getClient(addonID); | ||||||||||||||||||
| if (!client || !client.filePath) { | ||||||||||||||||||
| return null; | ||||||||||||||||||
| } | ||||||||||||||||||
| return client.filePath; | ||||||||||||||||||
| }); | ||||||||||||||||||
| ipcMain.handle('app:get-addon-icon', async (_, addonID: string) => { | ||||||||||||||||||
| let client = clients.get(addonID); | ||||||||||||||||||
| let client = addonServer.getClient(addonID); | ||||||||||||||||||
| if (!client || !client.filePath) { | ||||||||||||||||||
| return null; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
@@ -239,9 +244,9 @@ export default function handler(mainWindow: Electron.BrowserWindow) { | |||||||||||||||||
| join(__dirname, 'public'), | ||||||||||||||||||
| join(__dirname, 'config'), | ||||||||||||||||||
| // for each addon, add the basedir of the addon to the allowed dirs | ||||||||||||||||||
| ...Array.from(clients.values()) | ||||||||||||||||||
| .filter((client) => client.filePath) | ||||||||||||||||||
| .map((client) => client.filePath + '/'), | ||||||||||||||||||
| ...Array.from(addonServer.getConnections().values()) | ||||||||||||||||||
| .filter((connection) => connection.filePath) | ||||||||||||||||||
| .map((connection) => connection.filePath + '/'), | ||||||||||||||||||
| ]; | ||||||||||||||||||
|
|
||||||||||||||||||
| let realPath: string; | ||||||||||||||||||
|
|
||||||||||||||||||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: Nat3z/OpenGameInstaller
Length of output: 4155
🏁 Script executed:
Repository: Nat3z/OpenGameInstaller
Length of output: 4447
🏁 Script executed:
Repository: Nat3z/OpenGameInstaller
Length of output: 733
Make
addonServer.stop()awaitable or add proper close handling before restarting the server.The
addonServer.stop()method callsthis.server.close()synchronously (line 100 of packages/addon-server/lib/addon.ts), buthttp.Server.close()is asynchronous and doesn't block. InrestartAddonServer(), callingstop()without awaiting meansawait startAddonServer()runs before the port is fully released, creating a potentialEADDRINUSErace condition. Either makestop()return a Promise that waits for the close callback, or add explicit close handling in the restart flow.🤖 Prompt for AI Agents