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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review: guard reader.cancel() in finally, schema-level combined-attachment test
[._.]/ Adam Eivy4fc550668fc2
diff --git a/client/src/services/apiOpenClaw.js b/client/src/services/apiOpenClaw.jsindex b5d53187ca..783e50ee45 100644--- a/client/src/services/apiOpenClaw.js+++ b/client/src/services/apiOpenClaw.js@@ -89,6 +89,10 @@ export async function streamOpenClawMessage(sessionId, { message, context, attacbuffer += decoder.decode();if (buffer.trim()) flushEventBlock(buffer);} finally {- await reader.cancel();+ try {+ await reader.cancel();+ } catch {+ // ignore cancel errors to avoid masking the original error+ }}}diff --git a/server/routes/openclaw.js b/server/routes/openclaw.jsindex 992a93738a..acf2bab2d4 100644--- a/server/routes/openclaw.js+++ b/server/routes/openclaw.js@@ -65,7 +65,7 @@ const contextSchema = z.object({extraInstructions: z.string().trim().min(1).optional()}).optional();-const sendMessageSchema = z.object({+export const sendMessageSchema = z.object({message: z.string().trim().min(1),context: contextSchema,attachments: z.array(attachmentSchema).max(8).optional()diff --git a/server/routes/openclaw.test.js b/server/routes/openclaw.test.jsindex 088554e75c..2400fa3da0 100644--- a/server/routes/openclaw.test.js+++ b/server/routes/openclaw.test.js@@ -1,7 +1,7 @@import { describe, it, expect, vi, beforeEach } from 'vitest';import express from 'express';import { request } from '../lib/testHelper.js';-import openclawRoutes from './openclaw.js';+import openclawRoutes, { sendMessageSchema } from './openclaw.js';vi.mock('../integrations/openclaw/api.js', () => ({isConfigured: vi.fn(),@@ -330,17 +330,10 @@ describe('OpenClaw Routes', () => {expect(openclawApi.sendSessionMessage).not.toHaveBeenCalled();});- it('should return 400 when combined attachments exceed the 50 MB total limit', async () => {- openclawApi.isConfigured.mockResolvedValue({ configured: true, enabled: true });-+ it('should reject combined attachments exceeding the 50 MB total limit (schema-level)', () => {// Use 6 attachments each at 9,000,000 chars (each individually under the ~13.3M per-attachment cap)// Combined = 54,000,000 chars > ATTACHMENTS_TOTAL_BASE64_MAX_CHARS (50,000,000).- // A dedicated app instance with a higher body-parser limit is required here so Express- // parses the request and hands it to Zod, rather than rejecting it with 413 itself.- const bigApp = express();- bigApp.use(express.json({ limit: '100mb' }));- bigApp.use('/api/openclaw', openclawRoutes);-+ // Validated directly against the schema to avoid sending a ~54MB HTTP body in CI.const data = 'A'.repeat(9_000_000);const attachments = Array.from({ length: 6 }, () => ({sourceType: 'base64',@@ -349,13 +342,10 @@ describe('OpenClaw Routes', () => {kind: 'image'}));- const response = await request(bigApp)- .post('/api/openclaw/sessions/main/messages')- .send({ message: 'Combined too large', attachments });+ const result = sendMessageSchema.safeParse({ message: 'Combined too large', attachments });- expect(response.status).toBe(400);- expect(response.body.code).toBe('VALIDATION_ERROR');- expect(openclawApi.sendSessionMessage).not.toHaveBeenCalled();+ expect(result.success).toBe(false);+ expect(result.error.issues.some(i => i.path.includes('attachments'))).toBe(true);});it('should accept a valid base64 attachment within size limits', async () => {