From daf8c643459b3cd0a228e15f06fec8ca249cf78a Mon Sep 17 00:00:00 2001 From: DecDuck Date: Tue, 10 Feb 2026 17:18:17 +1100 Subject: [PATCH 1/2] fix: droplet interface not waiting for torrential --- server/internal/clients/ca.ts | 3 +++ server/internal/library/index.ts | 4 ++-- server/internal/services/index.ts | 12 ++++++++++++ .../services/torrential/droplet-interface.ts | 1 + server/internal/services/torrential/index.ts | 18 +++++++++++------- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/server/internal/clients/ca.ts b/server/internal/clients/ca.ts index 2e027d82..848032c8 100644 --- a/server/internal/clients/ca.ts +++ b/server/internal/clients/ca.ts @@ -1,5 +1,6 @@ import type { CertificateStore } from "./ca-store"; import { dropletInterface } from "../services/torrential/droplet-interface"; +import { logger } from "../logging"; export type CertificateBundle = { priv: string; @@ -35,6 +36,8 @@ export class CertificateAuthority { await ca.generateClientCertificate("server", "Drop Server"); } + logger.info("initialised the ca"); + return ca; } diff --git a/server/internal/library/index.ts b/server/internal/library/index.ts index da9bbcff..057f5ad6 100644 --- a/server/internal/library/index.ts +++ b/server/internal/library/index.ts @@ -493,8 +493,8 @@ class LibraryManager { notificationSystem.systemPush({ nonce: `version-create-${gameId}-${version}`, - title: `'${game.mName}' ('${version}') finished importing.`, - description: `Drop finished importing version ${version} for ${game.mName}.`, + title: `'${game.mName}' ('${version.name}') finished importing.`, + description: `Drop finished importing version ${version.name} for ${game.mName}.`, actions: [`View|/admin/library/${gameId}`], acls: ["system:import:version:read"], }); diff --git a/server/internal/services/index.ts b/server/internal/services/index.ts index e155182a..c019fe67 100644 --- a/server/internal/services/index.ts +++ b/server/internal/services/index.ts @@ -48,6 +48,9 @@ export class Service { private uutils: T; + private readyPromise: Promise; + private readyPromiseResolve: (() => void) | undefined; + constructor( name: string, executor: Executor, @@ -62,6 +65,9 @@ export class Service { this.setup = setup; this.healthcheck = healthcheck; this.uutils = utils!; + this.readyPromise = new Promise((r) => { + this.readyPromiseResolve = r; + }); } spin() { @@ -124,6 +130,8 @@ export class Service { } } this.healthy = true; + if (this.readyPromiseResolve) this.readyPromiseResolve(); + this.logger.info("service healthy"); } } @@ -157,6 +165,10 @@ export class Service { return this.healthy; } + async waitServiceHealthy() { + await this.readyPromise; + } + utils() { return this.uutils; } diff --git a/server/internal/services/torrential/droplet-interface.ts b/server/internal/services/torrential/droplet-interface.ts index a363f76a..8b8e5a2b 100644 --- a/server/internal/services/torrential/droplet-interface.ts +++ b/server/internal/services/torrential/droplet-interface.ts @@ -250,6 +250,7 @@ class DropletInterfaceManager { messageType: TorrentialBoundType, callbackType: KT, ): Promise["resolve"]>[0]> { + await TORRENTIAL_SERVICE.waitServiceHealthy(); const messageId = crypto.randomUUID(); await TORRENTIAL_SERVICE.writeMessage(messageId, { diff --git a/server/internal/services/torrential/index.ts b/server/internal/services/torrential/index.ts index a0b7211a..604b9fc7 100644 --- a/server/internal/services/torrential/index.ts +++ b/server/internal/services/torrential/index.ts @@ -59,7 +59,7 @@ export class TorrentialService extends Service { ); return spawn( "cargo", - ["run", "--manifest-path", "./torrential/Cargo.toml"], + ["run", "--manifest-path", "./torrential/Cargo.toml", "--release"], {}, ); } else { @@ -74,14 +74,15 @@ export class TorrentialService extends Service { return spawn("torrential", [], {}); }, async () => { - if (this.socket) return true; - this.socket = net.createConnection({ port: 33148, host: "127.0.0.1" }); - await new Promise((r) => - this.socket!.on("connect", () => { + const socket = net.createConnection({ port: 33148, host: "127.0.0.1" }); + await new Promise((r, j) => { + socket.on("connect", () => { this.logger.info("connected to torrential socket"); + this.socket = socket; r(); - }), - ); + }); + socket.on("error", (err) => j(err)); + }); this.setupRead(); return true; @@ -129,6 +130,8 @@ export class TorrentialService extends Service { data: T; }, ) { + if (!this.socket) throw "Not connected to torrential"; + const response = create(TorrentialBoundSchema, { messageId: messageId, type: value.type, @@ -146,6 +149,7 @@ export class TorrentialService extends Service { } private async queueRead() { + if (!this.socket) throw "Not connected to torrential"; if (this.readbuf.length < 8) return; const sizeBytes = this.readbuf.subarray(0, 8); const size = sizeBytes.readBigUInt64LE(0); From 9a2092ef1a3ea3ec4e60d887720d6b6d4fcdb254 Mon Sep 17 00:00:00 2001 From: DecDuck Date: Fri, 13 Feb 2026 13:08:14 +1100 Subject: [PATCH 2/2] fix: lint --- server/internal/services/torrential/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/internal/services/torrential/index.ts b/server/internal/services/torrential/index.ts index 604b9fc7..283d0c28 100644 --- a/server/internal/services/torrential/index.ts +++ b/server/internal/services/torrential/index.ts @@ -59,7 +59,12 @@ export class TorrentialService extends Service { ); return spawn( "cargo", - ["run", "--manifest-path", "./torrential/Cargo.toml", "--release"], + [ + "run", + "--manifest-path", + "./torrential/Cargo.toml", + "--release", + ], {}, ); } else {