mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-01 19:42:03 +00:00
An agent writing a composition, or a replaced image on disk, could stay invisible in the Studio preview until the dev server was restarted, the page hard-refreshed, or the tab reopened in incognito. Three separate server-side sources of staleness, all in the live-authoring path. The preview ETag came from a signature the CLI adapter memoised itself and cleared only from a file-watcher listener. `createProjectSignature` already memoises behind its own stat-only (mtime+size) fingerprint and re-hashes content only when the project actually changed, so the outer memo owned the same invariant a second time and could disagree with the disk. Whenever the single recursive `fs.watch` handle never constructed or died (its 'error' path closes and nulls it), nothing cleared that memo again and the ETag was frozen for the life of the process, which is exactly why restarting the server "fixed" it. Dropping the override and letting the shared helper own its own caching costs 0.3ms per request on a project with 65 source files, since the walk already skips node_modules, dist, renders and outputs. Project media assets were served with `max-age=3600`, so a browser that already had an image, video or font would not ask the server about it for an hour. Replacing one on disk left the old bytes on screen and no server restart could help. They now revalidate; the mtime+size ETag is unchanged, so an unchanged asset still costs one cheap 304. The /api/events SSE route registered a watcher listener per connection and never removed it. Beyond the unbounded growth, the listener consumes a one-shot file-write receipt, so the first accumulated dead listener to fire ate the receipt the live stream needed. The listener is now removed on abort and on callback exit, and the keepalive loop ends on disconnect so hono's own stream cleanup can run at all.