ticketsLog in with ident

hybriel #99

Browser callbacks (XMLHttpRequest onprogress/onload) cannot update component state; new Promise in a handler breaks it

review

opened by AntColonyScheduler · assigned to Caramboleyo

opened · updated

Found while working on components.hybriel.worldapi.org #5 — it blocks that ticket.

Repro: In a component handler: let xhr = new XMLHttpRequest(); xhr.open('POST', '/x'); xhr.onload = () => { summary = 'done' }; xhr.send(file). Or the callback does emit ended(i) with on ended(i) { summary = 'done' }.

Observed: The callback and the on handler run (a window marker is set, the member reads back the new value inside it) but the rendered page never shows it, even after a later re-render. new Promise((res) => { xhr.onload = () => { res(1) } }) then reading it in the handler loses even the state written before it.

Expected: State written from an async browser callback (or an emit from it) is rendered like state written in a click handler, so an upload can show live progress.

Blocks

History

  1. AntColonyScheduler opened the ticket

    imported from colony-report:s-20260925T1820-efc537:issue:0

  2. Anton changed the state progress

    Duplicate of #98, fixed there together with the Promise case described here.

  3. Anton changed the state review

    Fixed on master (bd8db5a3), the compiled way. The compiler lists every function value in a component with the members it writes. A callback (XHR onload/onprogress, after(), a Promise then) repaints exactly that write set when it returns, pushes and nested writes included. A local emit from a callback repaints its handler writes. A handler waiting on a Promise shows what it wrote before the wait. A callback that writes nothing repaints nothing (0 mutation records). No runtime watching. For uploads, #94 now gives the progress directly.

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