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(moltbook): handle platform unavailability gracefully

Adam Eivy26040acd6a33
diff --git a/.changelog/v0.12.x.md b/.changelog/v0.12.x.md
index 53f3b23f4e..77225731fc 100644
--- a/.changelog/v0.12.x.md
+++ b/.changelog/v0.12.x.md
@@ -556,6 +556,12 @@ This release adds branch management and automated release workflow capabilities
- `client/src/components/city/CityScene.jsx` — Adjusted camera position, fog distance, and orbit controls for larger city
- `client/src/components/city/CityRoads.jsx` — Wider road surfaces, edge lines, and padding for larger grid spacing
+### Agents — Graceful Moltbook Unavailability Handling
+- **Network failure handling**: When Moltbook is completely unreachable (DNS failure, connection refused, timeout), the API client now returns a structured `503 PLATFORM_UNAVAILABLE` error instead of crashing with a raw `TypeError`
+- **Upstream 5xx remapping**: Moltbook 500 errors are remapped to `503 PLATFORM_UNAVAILABLE` on our side, so PortOS doesn't appear to have internal errors when the upstream platform is down
+- **Warning-level logging**: Platform unavailability logs as `⚠️` warnings instead of `❌` errors with full stack traces, reducing log noise during outages
+- **UI warning toasts**: Client shows platform unavailability as a `⚠️` warning toast instead of a red error toast, making it clear the issue is upstream
+
### Agents — Moltbook Rate Limit Cooldown Timer & 429 Sync
- **Cooldown countdown timer**: Rate limit pills in ToolsTab and OverviewTab now show a live mm:ss countdown when a cooldown is active (e.g., `post: 24:35`), pulsing with `animate-pulse` for visibility. Timer auto-refreshes rate limits from the server when it reaches zero.
- **Publish button cooldown**: The Publish button disables during post cooldown and shows "Wait mm:ss" instead of "Publish", preventing wasted API calls
diff --git a/client/src/hooks/useErrorNotifications.js b/client/src/hooks/useErrorNotifications.js
index 4606a22e3d..a3a653e228 100644
--- a/client/src/hooks/useErrorNotifications.js
+++ b/client/src/hooks/useErrorNotifications.js
@@ -18,6 +18,13 @@ export function useErrorNotifications() {
// Handle error notifications from server
const handleError = (error) => {
+ // Platform unavailability is a warning, not an error
+ if (error.code === 'PLATFORM_UNAVAILABLE') {
+ toast(error.message, { duration: 5000, icon: '⚠️' });
+ console.warn(`[${error.code}] ${error.message}`, error.context);
+ return;
+ }
+
const toastOptions = {
duration: error.severity === 'critical' ? 10000 : 5000,
icon: error.severity === 'critical' ? '💥' : '❌'
diff --git a/client/src/services/api.js b/client/src/services/api.js
index f91e9d0945..0a0c6069d2 100644
--- a/client/src/services/api.js
+++ b/client/src/services/api.js
@@ -17,7 +17,12 @@ async function request(endpoint, options = {}) {
if (!response.ok) {
const error = await response.json().catch(() => ({ error: 'Request failed' }));
const errorMessage = error.error || `HTTP ${response.status}`;
- toast.error(errorMessage);
+ // Platform unavailability is a warning, not an error
+ if (error.code === 'PLATFORM_UNAVAILABLE') {
+ toast(errorMessage, { icon: '⚠️' });
+ } else {
+ toast.error(errorMessage);
+ }
throw new Error(errorMessage);
}
diff --git a/server/integrations/moltbook/api.js b/server/integrations/moltbook/api.js
index 76287ca2f2..ea2d0e56b7 100644
--- a/server/integrations/moltbook/api.js
+++ b/server/integrations/moltbook/api.js
@@ -80,7 +80,18 @@ async function request(endpoint, options = {}, aiConfig) {
console.log(`📚 Moltbook API: ${options.method || 'GET'} ${endpoint}`);
- const response = await fetch(url, config);
+ let response;
+ const fetchResult = await fetch(url, config).then(r => ({ ok: true, response: r }), e => ({ ok: false, error: e }));
+
+ if (!fetchResult.ok) {
+ console.error(`❌ Moltbook API unreachable: ${fetchResult.error.message}`);
+ const err = new Error('Moltbook is currently unavailable');
+ err.status = 503;
+ err.code = 'PLATFORM_UNAVAILABLE';
+ throw err;
+ }
+
+ response = fetchResult.response;
if (!response.ok) {
const error = await response.json().catch(() => ({}));
@@ -101,7 +112,9 @@ async function request(endpoint, options = {}, aiConfig) {
}
const err = new Error(message);
- err.status = response.status;
+ // Upstream 5xx → our 503 (platform unavailable), preserve 4xx as-is
+ err.status = response.status >= 500 ? 503 : response.status;
+ err.code = response.status >= 500 ? 'PLATFORM_UNAVAILABLE' : undefined;
err.suspended = response.status === 403 && message.toLowerCase().includes('suspended');
throw err;
}
diff --git a/server/lib/errorHandler.js b/server/lib/errorHandler.js
index 1306231232..9698ae6edf 100644
--- a/server/lib/errorHandler.js
+++ b/server/lib/errorHandler.js
@@ -34,9 +34,11 @@ export function asyncHandler(fn) {
const io = req.app.get('io');
const error = normalizeError(err);
- // Log the error
+ // Log the error (skip stack traces for upstream platform issues)
const logMsg = `❌ Route error: ${error.message}`;
- if (error.status >= 500) {
+ if (error.code === 'PLATFORM_UNAVAILABLE') {
+ console.warn(`⚠️ Platform unavailable: ${error.message}`);
+ } else if (error.status >= 500) {
console.error(logMsg, error.stack ? error.stack : '');
} else {
console.error(logMsg);