fix(plan-canvas): sanitize PDF failures

This commit is contained in:
haelyra
2026-08-28 17:38:33 -04:00
parent cbc35c098a
commit 103bbb272a
5 changed files with 98 additions and 24 deletions
+16
View File
@@ -17,6 +17,7 @@
*/
const assert = require('assert');
const { EventEmitter } = require('events');
const fs = require('fs');
const http = require('http');
const os = require('os');
@@ -169,6 +170,21 @@ async function main() {
);
});
await test('port-scoped startup lock propagates socket failures', async () => {
class FailingLockSocket extends EventEmitter {
bind(_port, _host, callback) { setImmediate(callback); }
unref() {}
close(callback) { if (callback) setImmediate(callback); }
}
const socket = new FailingLockSocket();
await assert.rejects(
withServerStartLock(port + 4, async () => {
socket.emit('error', new Error('simulated UDP failure'));
}, { dgramImpl: { createSocket: () => socket }, timeoutMs: 2000 }),
error => error.code === 'PLAN_CANVAS_START_LOCK_FAILED' && error.message.includes('simulated UDP failure')
);
});
await test('concurrent opens serialize replacement of a same-version legacy server', async () => {
const legacyPort = port + 1;
const legacyStateDir = path.join(tmp, 'legacy-state');