Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: harden migration file read and remove dead update subscriber code

Adam Eivy4fea60056475
diff --git a/scripts/run-migrations.js b/scripts/run-migrations.js
index 416edd37b1..47ef64bfe0 100644
--- a/scripts/run-migrations.js
+++ b/scripts/run-migrations.js
@@ -1,6 +1,5 @@
#!/usr/bin/env node
import { readdir, readFile, writeFile, mkdir } from 'fs/promises';
-import { existsSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath, pathToFileURL } from 'url';
@@ -13,10 +12,15 @@ async function run() {
// Ensure migrations directory exists
await mkdir(migrationsDir, { recursive: true });
- // Load applied migrations list (default to [] on corrupt file)
+ // Load applied migrations list (default to [] on read/parse failure)
let applied = [];
- if (existsSync(appliedFile)) {
- const raw = await readFile(appliedFile, 'utf-8');
+ const raw = await readFile(appliedFile, 'utf-8').catch(err => {
+ if (err.code !== 'ENOENT') {
+ console.warn(`⚠️ Could not read ${appliedFile}: ${err.message}, defaulting to []`);
+ }
+ return null;
+ });
+ if (raw !== null) {
try { applied = JSON.parse(raw); } catch { applied = []; }
if (!Array.isArray(applied)) applied = [];
}
diff --git a/server/services/socket.js b/server/services/socket.js
index f14cd372c9..5739220072 100644
--- a/server/services/socket.js
+++ b/server/services/socket.js
@@ -44,8 +44,6 @@ const notificationSubscribers = new Set();
const agentSubscribers = new Set();
// Store instance subscribers
const instanceSubscribers = new Set();
-// Store update subscribers
-const updateSubscribers = new Set();
// Store io instance for broadcasting
let ioInstance = null;
@@ -257,17 +255,6 @@ export function initSocket(io) {
socket.emit('instances:unsubscribed');
});
- // Update subscriptions
- socket.on('update:subscribe', () => {
- updateSubscribers.add(socket);
- socket.emit('update:subscribed');
- });
-
- socket.on('update:unsubscribe', () => {
- updateSubscribers.delete(socket);
- socket.emit('update:unsubscribed');
- });
-
// Handle error recovery requests (can trigger auto-fix agents)
socket.on('error:recover', async (rawData) => {
const data = validateSocketData(errorRecoverSchema, rawData, socket, 'error:recover');
@@ -426,7 +413,6 @@ export function initSocket(io) {
notificationSubscribers.delete(socket);
agentSubscribers.delete(socket);
instanceSubscribers.delete(socket);
- updateSubscribers.delete(socket);
// Clean up any shell sessions for this socket
const shellsClosed = shellService.cleanupSocketSessions(socket);
if (shellsClosed > 0) {
@@ -663,20 +649,16 @@ function setupPeerAgentEventForwarding() {
instanceEvents.on('peer:agent:completed', (data) => broadcastToInstances('instances:peer:agent:completed', data));
}
-// Broadcast to update subscribers only
-function broadcastToUpdate(event, data) {
- for (const socket of updateSubscribers) {
- socket.emit(event, data);
- }
-}
-
// Set up update event forwarding
function setupUpdateEventForwarding() {
updateEvents.on('update:available', (data) => {
- // Broadcast to all clients so global toast can appear
if (ioInstance) {
ioInstance.emit('portos:update:available', data);
}
});
- updateEvents.on('update:checked', (data) => broadcastToUpdate('portos:update:checked', data));
+ updateEvents.on('update:checked', (data) => {
+ if (ioInstance) {
+ ioInstance.emit('portos:update:checked', data);
+ }
+ });
}