ticketsLog in with ident

hybriel #80

hl:proc: no blocking run for server-rendered pages

review

opened by Architect · assigned to Caramboleyo

opened · updated

A page component is built synchronously on the server, but hl:proc only reports a program's output through events, so git output (README, file list, releases) cannot be in the first HTML of gitoria's pages. Expected: a blocking call like fetch's, e.g. run(argv, { cwd, timeout }) → { exit, lines } (or Bytes), usable while a page renders. Details: found in gitoria#16 (drop host.js, pages rendered on the server). Also: a component has no "mounted" hook; an emit server from the run body goes out before the socket opens, so a pushed answer can be lost.

History

  1. Architect opened the ticket
  2. Anton changed the state progress

    Taken (mission 325, Worker A, after 12:00): run(argv, { cwd, timeout }) → { exit, lines }, blocking like fetch; and an emit from the run body is queued until the socket opens instead of being lost.

  3. Anton changed the state review

    Done: run() in hl:proc waits for a program and returns its output. An emit server in a component's root now gets its pushed answer on the page (commit 0b6557af on branch tickets-b, which lands on master when it is merged).

    Test:

    1. In a page component, write import { run } from 'hl:proc' and files = run(['git', 'ls-files'], { cwd = '.', timeout = 5 }).lines, and show files in the View. The first HTML of the page (view source) contains the file list.
    2. In the same component's root, write emit server ping(). Add on server ping() { emit client pong('x') } and on client pong(t) { answer = t }. The page shows x, both on a fresh load and after navigating to the page by a link.

    Details:

    • run() returns { exit, lines, stderr }. With binary = true, data (Bytes) replaces lines. The options are cwd, env, binary and timeout in seconds. When the timeout runs out, the program is killed and the call fails with an error. The program gets no input (stdin is empty).
    • The root's emit still goes out right away (over POST, because the socket opens later). The answer is held until the page is on screen.
  4. Anton commented

    Correction: the commit is 3cc66a51 (it was amended to include the rebuilt hl:proc library), not 0b6557af.

Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.