@donkeylabs/server 2.5.0 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donkeylabs/server",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "type": "module",
5
5
  "description": "Type-safe plugin system for building RPC-style APIs with Bun",
6
6
  "main": "./src/index.ts",
@@ -49,12 +49,12 @@ export class KyselyProcessAdapter implements ProcessAdapter {
49
49
  this.db = db as Kysely<Database>;
50
50
  this.cleanupDays = config.cleanupDays ?? 7;
51
51
 
52
- // Start cleanup timer
52
+ // Start cleanup timer - delay initial cleanup to allow migrations to run first
53
53
  if (this.cleanupDays > 0) {
54
54
  const interval = config.cleanupInterval ?? 3600000; // 1 hour
55
55
  this.cleanupTimer = setInterval(() => this.cleanup(), interval);
56
- // Run cleanup on startup
57
- this.cleanup();
56
+ // Delay initial cleanup to ensure table exists after migrations
57
+ setTimeout(() => this.cleanup(), 5000);
58
58
  }
59
59
  }
60
60
 
@@ -226,19 +226,28 @@ export class KyselyProcessAdapter implements ProcessAdapter {
226
226
  async getOrphaned(): Promise<ManagedProcess[]> {
227
227
  if (this.checkStopped()) return [];
228
228
 
229
- const rows = await this.db
230
- .selectFrom("__donkeylabs_processes__")
231
- .selectAll()
232
- .where((eb) =>
233
- eb.or([
234
- eb("status", "=", "running"),
235
- eb("status", "=", "spawning"),
236
- eb("status", "=", "orphaned"),
237
- ])
238
- )
239
- .execute();
229
+ try {
230
+ const rows = await this.db
231
+ .selectFrom("__donkeylabs_processes__")
232
+ .selectAll()
233
+ .where((eb) =>
234
+ eb.or([
235
+ eb("status", "=", "running"),
236
+ eb("status", "=", "spawning"),
237
+ eb("status", "=", "orphaned"),
238
+ ])
239
+ )
240
+ .execute();
240
241
 
241
- return rows.map((r) => this.rowToProcess(r));
242
+ return rows.map((r) => this.rowToProcess(r));
243
+ } catch (err: any) {
244
+ // Silently ignore if table doesn't exist yet (migrations not run)
245
+ const message = err?.message?.toLowerCase() || "";
246
+ if (message.includes("does not exist") || message.includes("no such table")) {
247
+ return [];
248
+ }
249
+ throw err;
250
+ }
242
251
  }
243
252
 
244
253
  private rowToProcess(row: ProcessesTable): ManagedProcess {