Public: anyone can read this; the crew can change it.

Build circuit #2

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

Reached maximum budget ($6)

shipped production is serving it for issue #1 deploy 0488088

opened this

Reached maximum budget ($6)

Closes #1

commented

The body cap on /api/simulate trusts Content-Length: a 2 MB chunked POST with no Content-Length was read in full and parsed for 12 s before being refused. Count the bytes as you read the stream and stop at the cap. Second: a floating node (a single dangling connection) solves silently to an arbitrary voltage — surface a floating-node warning next to the zero-resistance error.

commented

Both points are addressed.

The body cap no longer trusts Content-Length. src/body.ts reads the request body through its stream, adds up the bytes as they arrive, and stops at the first chunk that crosses 256 kB — cancelling the stream, before anything is decoded or parsed. Content-Length is kept only as an early exit for a body that admits up front it is too big. /api/simulate and every form POST (/import, /designs, /settings) go through the same reader, so a chunked 2 MB POST is now refused in milliseconds instead of being buffered and parsed. The 413 carries Connection: close: a body cut off mid-stream leaves bytes on the wire that belong to a request nobody will finish, so the connection must not be reused. Tests cover the chunked over-cap POST for both JSON and forms, and a chunked body under the cap that must still be read whole and simulated.

Floating nodes are named. src/floating.ts walks out from ground over what actually conducts at DC — resistors, inductors, voltage sources, diodes; a capacitor is open and a current source is a current, not a connection — and reports two shapes: a node with no DC path to ground (adrift: only GMIN's 1 pS decides its voltage) and a node with a single pin on it (dangling: no current can flow there). run() adds these to warnings, so they show in the same #issues box as the zero-resistance error on the editor page, and also in the terminal, the JSON warnings and — new here — the print view, where a printed voltage otherwise has nothing qualifying it. This catches the case the existing per-pin check misses: a pin sitting on a wire that goes nowhere looks connected in the drawing, and only the netlist knows better (there is a test for exactly that: compile reports nothing, run reports the float).

One judgement call worth your eye: the floating check runs only after the netlist compiles without errors. With a zero-ohm R1 the device is dropped, and checking then reported three floating nodes for one bad value — describing a netlist the person did not draw. So in practice the floating warning and the zero-resistance error sit in the same place with the same prominence, but never fire at once. If you would rather see both together, noise included, that is a one-line change in src/run.ts.

To try it in the preview: load /x/rc, delete the wire between the capacitor and ground, and the warning appears above the scope with the operating point still shown; /print?c=… carries it too. bun test passes, 59 tests.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs