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

Migrated from github.com/Trevato/SO-ARM100

Grow light schedule: a switch driver (smart plug, GPIO relay, or uhubctl only when it switches the light alone) with a photoperiod that runs on the Pi #599

opened this

Merged 39d 23h ago

I merged main into the branch and pushed it as 522df96. The branch tip fac507b already held main's files (including the pump) but had main as neither parent nor ancestor, which is why the forge reported 15 conflicts.

Notes

opened this

I merged main into the branch and pushed it as 522df96. The branch tip fac507b already held main's files (including the pump) but had main as neither parent nor ancestor, which is why the forge reported 15 conflicts. Taking the branch's own version of every conflicting file removed them, and main is now an ancestor of the branch.

The branch now differs from main in two files only. I ran the light, server, terminal and admin-relay tests: 153 pass, 0 fail.

  • server.ts: POST /grow/<device> now answers 413 when a body goes past the 1 MB cap. Before, the server destroyed the request and the client waited for an answer that never came. Other routes that read a body share this path and get the same change. It also stops reading the rest of the body and sets Connection: close.
  • light-endpoint.test.ts: the old body-cap test accepted a dropped connection as a pass. The new one sends 4 MB chunked with no Content-Length over a raw socket, to both /grow/light and /grow/pump. It checks that a 413 comes back within a second, and that nothing was configured afterwards.

Bun's node:http did not close the socket after the 413, even when I destroyed it explicitly. So the server answers promptly and stops reading, but I couldn't make it hang up, and the test doesn't assert a hang-up.

Continues #599

7 earlier comments · 1 event
commented

Agreed that #582's scope is already on main (82337a2, #596). I merged main into the branch with main's light and pump kept as they landed, so the pull now differs from main by two files: a stricter body-cap test and the one-line server fix it exposed.

The old test didn't hold the cap tightly: it passed on a dropped connection, and it never saw the real behaviour. readBody in server.ts called req.destroy() at 1 MB. The client got no answer and waited until its own timeout. That affects every route that reads a JSON body, POST /grow/<device> included.

  • Fix (server.ts): on overflow, readBody now stops reading, drops what it held and rejects with 413. The error handler sends connection: close with the 413, so the client hears "body too large".
  • Test (light-endpoint.test.ts): a raw-socket test sends a 4 MB chunked body with no Content-Length to /grow/light and /grow/pump. It requires a 413 reply within a second and checks that the device is still unconfigured afterwards.

On the old server the new test fails; with the fix it passes. The light-endpoint, light, server and admin-relay tests pass (107). tsc is clean for the two files I changed. I didn't run the whole suite.

The server still keeps the connection open after the 413 rather than closing it itself. The client closes it after the answer, and the test ends the connection that way. A person should still close #582 against 82337a2.

commented

I merged main into the branch and pushed it as 522df96. The branch tip fac507b already held main's files (including the pump) but had main as neither parent nor ancestor, which is why the forge reported 15 conflicts. Taking the branch's own version of every conflicting file removed them, and main is now an ancestor of the branch.

The branch now differs from main in two files only. I ran the light, server, terminal and admin-relay tests: 153 pass, 0 fail.

  • server.ts: POST /grow/<device> now answers 413 when a body goes past the 1 MB cap. Before, the server destroyed the request and the client waited for an answer that never came. Other routes that read a body share this path and get the same change. It also stops reading the rest of the body and sets Connection: close.
  • light-endpoint.test.ts: the old body-cap test accepted a dropped connection as a pass. The new one sends 4 MB chunked with no Content-Length over a raw socket, to both /grow/light and /grow/pump. It checks that a 413 comes back within a second, and that nothing was configured afterwards.

Bun's node:http did not close the socket after the 413, even when I destroyed it explicitly. So the server answers promptly and stops reading, but I couldn't make it hang up, and the test doesn't assert a hang-up.

the crew's run was interrupted: clone, resumes on the next pass — checkout failed: error: could not lock config file .git/config: File exists error: unable to write upstream branch configuration hint: hint: After fixing the error cause you may try to fix up hint: the remote tracking
commented

This pull has no new feature work. The issue was already done on main in 82337a2 (#596, which also brought the pump), so what remains here is a small server fix and its test, and I merged the latest main (#597) into the branch.

  • Server: POST /grow/<device> answers 413 when a body passes the 1 MB cap. Before, the client waited for an answer that never came. Other routes that read a body share this path and get the same change. It stops reading the rest of the body and sets Connection: close.
  • Test: light-endpoint.test.ts sends 4 MB chunked with no Content-Length over a raw socket, to both /grow/light and /grow/pump. It checks that a 413 comes back within a second, and that nothing was configured afterwards. This run I gave it a longer watchdog and a 15 s test timeout, because it failed once when the machine was under load.
  • Hang-up: Bun's node:http did not close the socket after the 413, so the server answers promptly but does not hang up, and the test doesn't assert a hang-up.
  • Tests: the light, grow-hint, terminal and admin-relay tests pass (91 pass, 0 fail). I did not run the whole suite.
  • Failing test on main: in server.test.ts, "serves the model, its meshes and the vendored libraries" fails on a clean main checkout too. I didn't touch it.

A person can close #582 as done.

commented

I made no changes this run. main hasn't moved since the last push, and the branch already contains it and has nothing new to push.

The branch differs from main in two files only: the 413 response for an over-cap body in server.ts, and its raw-socket test in light-endpoint.test.ts. I didn't re-run the tests this time.

#582 itself is done on main in 82337a2 (#596). The light, the drivers and the uhubctl camera refusal are there, along with the owner-only /grow routes, the terminal door and the pump. #597 (the camera hint) is there too. A person can close #582 and merge the pull for the body-cap fix.

commented

I made no changes this run, and nothing was pushed. main is unchanged since my last run (315c1ae, #597), and the branch already contains it and matches its remote.

Nothing new has moved on #582. The issue's work is on main in 82337a2 (#596): the light schedule, the three switch drivers, the owner-only /grow routes, the terminal command and the pump. This branch's only remaining change is the 413 response for an over-cap request body, with its raw-socket test. A person can close #582 and merge that pull.

commented

I made no changes this run, and nothing was pushed. main is still at 315c1ae (#597), the branch already contains it, and the branch matches its remote.

The work for #582 is on main in 82337a2 (#596). The branch's only remaining change is the 413 response for an over-cap request body, with its test. A person can close #582 and merge that pull.

commented

I made no changes this run, and nothing was pushed. main is still at 315c1ae (#597), the branch already contains it, and the branch matches its remote.

The work for #582 is on main in 82337a2 (#596). The branch's only remaining change is the 413 response for an over-cap request body, with its test. A person can close #582 and merge that pull.

commented

This pull is a side fix. The grow light schedule from #582 is already on main (82337a2). What this pull changes is how POST /grow/<device> handles an oversized body.

  • Body cap in bytes: readBody in Software/so101/src/server.ts now keeps the chunks as Buffers and keeps a running byte total. It compares that total to MAX_BODY and decodes once at the end. Before, it counted UTF-16 characters, so a body of 3-byte characters got through at about 3 MB.
  • New test: light-endpoint.test.ts posts 600k of € (1.8 MB, under 1M characters) and expects 413 and no change to the light config. The light-endpoint tests pass. I did not run the type check: tsc could not find the bun type definitions in this environment.
  • Known gap: the server still does not hang up after the 413, and the test does not assert it. That is in follow-up issue #600.
Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs