Skip to content

fix(layout): fail the layout when ELK's thread or child process dies - #66

Merged
hyamero merged 1 commit into
stagingfrom
fix/layout-fails-on-dead-elk
Oct 24, 2026
Merged

hyamero merged 1 commit into
stagingfrom
fix/layout-fails-on-dead-elk

Conversation

@hyamero

@hyamero hyamero commented Oct 23, 2026

Copy link
Copy Markdown
Member

What and why

Large diagrams lay out with ELK in a Node worker thread, or under Bun in a child process. Three ways that thread or process could die weren't handled:

  • The thread exits without an 'error' event: the layout promise never settled, so deliver hung with no exit code, and serve stalled every later rebuild.
  • The child's stdout isn't valid JSON: JSON.parse threw inside a 'close' listener, as an uncaught exception.
  • The child dies before reading its input: EPIPE on its stdin was an unhandled 'error' event that crashed the process.

The thread bridge and child runner move into src/elk-io.ts. threadPort fails pending requests on 'exit', and runChild settles once and rejects on every failure path, naming the signal when the child is killed. The Bun child path now gets a real dispose that kills any leftover child. A rejected layout already becomes a clean exit 2 in the CLI. The comment on mainThreadElk now says it is Bun's large-graph host on Windows.

How it was checked

  • New test/elk-io.test.ts has 8 cases, using hand-built fake threads and children:
    • exit with pending work;
    • exit after an answer;
    • an 'error' event;
    • valid JSON;
    • truncated JSON;
    • a kill by signal;
    • EPIPE on stdin;
    • settling once.
  • bun run test passes (including the 500-node stress case), the Bun smoke still matches the baked layouts, and the deliver determinism smoke passes. Layout output is unchanged.

@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
stackmap-site Ready Ready Preview Oct 23, 2026 4:43pm UTC

@hyamero
hyamero merged commit ef35c5c into staging Oct 24, 2026
7 checks passed
@hyamero
hyamero deleted the fix/layout-fails-on-dead-elk branch October 24, 2026 04:08
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.6.1-rc.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.6.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

This branch was successfully deployed

1 active deployment
Preview — 3e815939 Deployed Oct 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant