The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(build): propagate icon and queued-open failures
ethernet41883016249f
diff --git a/apps/desktop/scripts/fs-open-limit.cjs b/apps/desktop/scripts/fs-open-limit.cjsindex 3b78aafab78..cc4b2dcf4f8 100644--- a/apps/desktop/scripts/fs-open-limit.cjs+++ b/apps/desktop/scripts/fs-open-limit.cjs@@ -87,13 +87,21 @@ if (!globalThis.__hermesFsOpenLimited && LIMIT > 0) {const pump = () => {while (active < LIMIT && queue.length > 0) {active += 1- queue.shift()()+ try {+ queue.shift()()+ } catch (err) {+ // Invalid arguments never install a completion callback.+ active -= 1+ queueMicrotask(pump)+ throw err+ }}}const release = () => {active -= 1- pump()+ // A queued validation error must not suppress the completed callback.+ queueMicrotask(pump)}// ── fs.open (callback form) ───────────────────────────────────────diff --git a/apps/desktop/scripts/fs-open-limit.test.mjs b/apps/desktop/scripts/fs-open-limit.test.mjsindex 64aad197c14..1e8402df4e9 100644--- a/apps/desktop/scripts/fs-open-limit.test.mjs+++ b/apps/desktop/scripts/fs-open-limit.test.mjs@@ -66,8 +66,7 @@ await walk(${JSON.stringify(root)})console.log('WALK_OK')`-test('the unbounded walk hits EMFILE under a low fd limit', () => {- if (!POSIX) return+test.skipIf(!POSIX)('the unbounded walk hits EMFILE under a low fd limit', () => {// The bug, reproduced. If this ever stops failing, the test below is// no longer proving anything and the preload could be silently useless.const tree = mkTree(3000)@@ -80,8 +79,7 @@ test('the unbounded walk hits EMFILE under a low fd limit', () => {}})-test('the preload lets the same walk finish under the same limit', () => {- if (!POSIX) return+test.skipIf(!POSIX)('the preload lets the same walk finish under the same limit', () => {const tree = mkTree(3000)try {const res = runNode(WALK_BODY(tree), { preload: true, ulimit: 64 })@@ -92,8 +90,7 @@ test('the preload lets the same walk finish under the same limit', () => {}})-test('both fs.open forms are queued, so a huge fan-out survives', () => {- if (!POSIX) return+test.skipIf(!POSIX)('both fs.open forms are queued, so a huge fan-out survives', () => {// isbinaryfile uses promisify(fs.open) (the callback form) while the// walk itself uses fs.promises.open — the patch has to cover both, or// half the demand escapes the queue.@@ -133,8 +130,7 @@ console.log('BOTH_FORMS_OK')assert.match(res.stdout, /BOTH_FORMS_OK/)})-test('the callback fan-out DOES fail without the preload', () => {- if (!POSIX) return+test.skipIf(!POSIX)('the callback fan-out DOES fail without the preload', () => {// Guards the test above: if 400 open+close cycles were survivable// unpatched, it would prove nothing about the queue.const body = `@@ -194,8 +190,7 @@ console.log('QUEUE_STILL_LIVE')assert.match(res.stdout, /QUEUE_STILL_LIVE/)})-test('holding descriptors while opening more cannot deadlock', () => {- if (!POSIX) return+test.skipIf(!POSIX)('holding descriptors while opening more cannot deadlock', () => {// The slot is released when open() SETTLES, not when the fd closes, so a// task holding many descriptors occupies no slots. Gating the fd lifetime// instead deadlocks — that is the design this asserts against.diff --git a/apps/desktop/scripts/fs-open-sync-throw.test.mjs b/apps/desktop/scripts/fs-open-sync-throw.test.mjsnew file mode 100644index 00000000000..c594b127d99--- /dev/null+++ b/apps/desktop/scripts/fs-open-sync-throw.test.mjs@@ -0,0 +1,72 @@+import assert from 'node:assert/strict'+import { spawnSync } from 'node:child_process'+import fs from 'node:fs'+import os from 'node:os'+import path from 'node:path'+import { test } from 'vitest'++const PRELOAD = path.join(import.meta.dirname, 'fs-open-limit.cjs')++function runNode(body) {+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'fsopen-sync-'))+ const script = path.join(dir, 'body.mjs')+ try {+ fs.writeFileSync(script, body)+ return spawnSync(process.execPath, ['--require', PRELOAD, script], {+ cwd: dir,+ encoding: 'utf8',+ timeout: 15000,+ env: { ...process.env, NODE_OPTIONS: '', HERMES_FS_OPEN_LIMIT: '1' },+ })+ } finally {+ fs.rmSync(dir, { recursive: true, force: true })+ }+}++test('immediate validation errors preserve throws and rejections without consuming slots', () => {+ const result = runNode(`+import assert from 'node:assert/strict'+import fs from 'node:fs'+for (let i = 0; i < 3; i++) {+ assert.throws(() => fs.open(1, 'r', () => {}), { code: 'ERR_INVALID_ARG_TYPE' })+}+await assert.rejects(fs.promises.open(1, 'r'), { code: 'ERR_INVALID_ARG_TYPE' })+const file = await fs.promises.open(new URL(import.meta.url), 'r')+await file.close()+console.log('SLOTS_RELEASED')+`)+ assert.equal(result.status, 0, result.error?.message || result.stderr)+ assert.match(result.stdout, /SLOTS_RELEASED/)+})++test('a deferred validation throw cannot suppress a settled callback or strand queued work', () => {+ const result = runNode(`+import assert from 'node:assert/strict'+import fs from 'node:fs'+const errors = []+const completed = []+process.on('uncaughtException', error => { errors.push(error) })+function open(name) {+ return new Promise((resolve, reject) => {+ fs.open(new URL(import.meta.url), 'r', (error, fd) => {+ if (error) { reject(error); return }+ fs.close(fd, closeError => {+ if (closeError) { reject(closeError); return }+ completed.push(name)+ resolve()+ })+ })+ })+}+const first = open('first')+fs.open(1, 'r', () => { throw new Error('validation must throw, not call back') })+const last = open('last')+await Promise.all([first, last])+assert.equal(errors.length, 1)+assert.equal(errors[0].code, 'ERR_INVALID_ARG_TYPE')+assert.deepEqual(completed.sort(), ['first', 'last'])+console.log('QUEUE_DRAINED')+`)+ assert.equal(result.status, 0, result.error?.message || result.stderr)+ assert.match(result.stdout, /QUEUE_DRAINED/)+})diff --git a/scripts/generate_icons.py b/scripts/generate_icons.pyindex d8d27b4bc82..c65397418d8 100644--- a/scripts/generate_icons.py+++ b/scripts/generate_icons.py@@ -385,18 +385,21 @@ def target_bytes(kind: str, arg: object) -> bytes:return buf.getvalue()-def cmd_write() -> None:+def cmd_write() -> int:+ """Return failure when any target cannot be generated or verified."""ensure_masters()written = 0+ failures = 0for rel, kind, arg in TARGETS:path = ROOT / rel- path.parent.mkdir(parents=True, exist_ok=True)try:+ path.parent.mkdir(parents=True, exist_ok=True)path.write_bytes(target_bytes(kind, arg))written += 1- except Exception as exc: # noqa: BLE001 - report and keep going+ except Exception as exc: # noqa: BLE001 - report all, then fail+ failures += 1print(f" !! {rel}: FAILED ({exc})")- print(f"[ok] wrote {written}/{len(TARGETS)} files")+ print(f"[write] wrote {written}/{len(TARGETS)} files")print("\n[verify]")for rel, kind, arg in TARGETS:@@ -420,8 +423,11 @@ def cmd_write() -> None:else:print(f" {rel}: {im.format} {im.size}")except Exception as exc:+ failures += 1print(f" {rel}: VERIFY FAILED ({exc})")+ return int(failures > 0)+def cmd_check() -> int:"""Structural verification: regenerate every target in memory and assert@@ -508,7 +514,7 @@ def cmd_check() -> int:def main() -> None:if "--check" in sys.argv:sys.exit(cmd_check())- cmd_write()+ sys.exit(cmd_write())if __name__ == "__main__":diff --git a/tests/scripts/test_icon_generation_exit.py b/tests/scripts/test_icon_generation_exit.pynew file mode 100644index 00000000000..8f287e7c8b1--- /dev/null+++ b/tests/scripts/test_icon_generation_exit.py@@ -0,0 +1,50 @@+"""Icon generation reports per-target failures without hiding later targets."""+import importlib.util+import io+import sys+from pathlib import Path+from types import ModuleType++import pytest+from PIL import Image++[email protected]("failure", [None, "render", "directory", "verify"])+def test_write_status_includes_every_target(tmp_path, monkeypatch, capsys, failure):+ # The renderer is build-only. This test injects failures at its byte boundary.+ monkeypatch.setitem(sys.modules, "resvg_py", ModuleType("resvg_py"))+ script = Path(__file__).resolve().parents[2] / "scripts" / "generate_icons.py"+ spec = importlib.util.spec_from_file_location("icon_generator_under_test", script)+ module = importlib.util.module_from_spec(spec)+ spec.loader.exec_module(module)+ monkeypatch.setattr(module, "ROOT", tmp_path)+ monkeypatch.setattr(module, "ensure_masters", lambda: None)+ monkeypatch.setattr(sys, "argv", [str(script)])++ image = io.BytesIO()+ Image.new("RGBA", (2, 2), (0, 0, 0, 0)).save(image, "PNG")+ good_bytes = image.getvalue()+ first = "blocked/icon.png" if failure == "directory" else "first.png"+ if failure == "directory":+ (tmp_path / "blocked").write_text("not a directory", encoding="utf-8")+ monkeypatch.setattr(module, "TARGETS", [(first, "png", "first"), ("last.png", "png", "last")])++ def target_bytes(kind, target):+ if target == "first":+ if failure == "render":+ raise RuntimeError("injected render failure")+ if failure == "verify":+ return b"not an image"+ return good_bytes++ monkeypatch.setattr(module, "target_bytes", target_bytes)+ code = 0+ try:+ module.main()+ except SystemExit as stopped:+ code = stopped.code+ assert bool(code) is (failure is not None)+ assert (tmp_path / "last.png").read_bytes() == good_bytes+ output = capsys.readouterr().out+ assert "last.png: PNG (2, 2)" in output+ assert ("FAILED" in output) is (failure is not None)