mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 20:44:32 -05:00
:electron: Fix early server-started signification message (#5303)
* fix issue where server was telling parent process it was ready but was not finished listening * release notes
This commit is contained in:
@@ -56,6 +56,10 @@ export function ElectronServerConfig({
|
||||
const [startingSyncServer, setStartingSyncServer] = useState(false);
|
||||
|
||||
const onConfigureSyncServer = async () => {
|
||||
if (startingSyncServer) {
|
||||
return; // Prevent multiple clicks
|
||||
}
|
||||
|
||||
if (
|
||||
isNaN(electronServerPort) ||
|
||||
electronServerPort <= 0 ||
|
||||
@@ -221,23 +225,23 @@ export function ElectronServerConfig({
|
||||
>
|
||||
<Label title={t('')} style={{ textAlign: 'left', width: '7ch' }} />
|
||||
{!electronSyncServerRunning ? (
|
||||
<Button
|
||||
<ButtonWithLoading
|
||||
variant="primary"
|
||||
style={{ padding: 10, width: '8ch' }}
|
||||
onPress={onConfigureSyncServer}
|
||||
isPending={startingSyncServer}
|
||||
isLoading={startingSyncServer}
|
||||
>
|
||||
<Trans>Start</Trans>
|
||||
</Button>
|
||||
</ButtonWithLoading>
|
||||
) : (
|
||||
<Button
|
||||
<ButtonWithLoading
|
||||
variant="primary"
|
||||
style={{ padding: 10, width: '8ch' }}
|
||||
onPress={onConfigureSyncServer}
|
||||
isPending={startingSyncServer}
|
||||
isLoading={startingSyncServer}
|
||||
>
|
||||
<Trans>Save</Trans>
|
||||
</Button>
|
||||
</ButtonWithLoading>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -156,6 +156,15 @@ function parseHTTPSConfig(value: string) {
|
||||
return fs.readFileSync(value);
|
||||
}
|
||||
|
||||
function sendServerStartedMessage() {
|
||||
// Signify to any parent process that the server has started. Used in electron desktop app
|
||||
// @ts-ignore-error electron types
|
||||
process.parentPort?.postMessage({ type: 'server-started' });
|
||||
console.log(
|
||||
'Listening on ' + config.get('hostname') + ':' + config.get('port') + '...',
|
||||
);
|
||||
}
|
||||
|
||||
export async function run() {
|
||||
const portVal = config.get('port');
|
||||
const port = typeof portVal === 'string' ? parseInt(portVal) : portVal;
|
||||
@@ -186,16 +195,12 @@ export async function run() {
|
||||
key: parseHTTPSConfig(config.get('https.key')),
|
||||
cert: parseHTTPSConfig(config.get('https.cert')),
|
||||
};
|
||||
https.createServer(httpsOptions, app).listen(port, hostname);
|
||||
https.createServer(httpsOptions, app).listen(port, hostname, () => {
|
||||
sendServerStartedMessage();
|
||||
});
|
||||
} else {
|
||||
app.listen(port, hostname);
|
||||
app.listen(port, hostname, () => {
|
||||
sendServerStartedMessage();
|
||||
});
|
||||
}
|
||||
|
||||
// Signify to any parent process that the server has started. Used in electron desktop app
|
||||
// @ts-ignore-error electron types
|
||||
process.parentPort?.postMessage({ type: 'server-started' });
|
||||
|
||||
console.log(
|
||||
'Listening on ' + config.get('hostname') + ':' + config.get('port') + '...',
|
||||
);
|
||||
}
|
||||
|
||||
6
upcoming-release-notes/5303.md
Normal file
6
upcoming-release-notes/5303.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Bugfix
|
||||
authors: [MikesGlitch]
|
||||
---
|
||||
|
||||
Fix server-started message invoking too early, causing desktop app server configuration flakiness.
|
||||
Reference in New Issue
Block a user