The link-type cache remembers every URL the window has ever seen #140

Closed
opened 2026-09-07 17:52:36 -04:00 by Salastil · 1 comment
Owner

The problem

lib/sniff.ts probes the content type of links that extension- and host-based
detection cannot classify, and shares the answers across rows so the same link
is never probed twice. The sharing is right; the remembering had no end to it.

One entry per URL ever seen, held for the life of the window. Worse, notify()
copies the entire record on every new answer so that selectors see a new
reference - so the cost of one answer grows with the number of answers already
given, and every row subscribed to it re-renders.

A session that had read a few busy channels was carrying tens of thousands of
URLs to save a request it was never going to make again.

The solution

A ceiling of 500. Insertion order is age order for string keys that are not
array indices, which a URL never is, so the oldest simply go first - which in
a chat log means the ones furthest up the scroll.

Fixed in 46e3d7f "Draw the part of the log somebody is reading".

## The problem `lib/sniff.ts` probes the content type of links that extension- and host-based detection cannot classify, and shares the answers across rows so the same link is never probed twice. The sharing is right; the remembering had no end to it. One entry per URL ever seen, held for the life of the window. Worse, `notify()` copies the entire record on every new answer so that selectors see a new reference - so the cost of one answer grows with the number of answers already given, and every row subscribed to it re-renders. A session that had read a few busy channels was carrying tens of thousands of URLs to save a request it was never going to make again. ## The solution A ceiling of 500. Insertion order is age order for string keys that are not array indices, which a URL never is, so the oldest simply go first - which in a chat log means the ones furthest up the scroll. Fixed in 46e3d7f "Draw the part of the log somebody is reading".
Salastil added the buglow priority labels 2026-09-07 17:52:36 -04:00
Author
Owner

Finished - 46e3d7f953

Finished - https://git.salastil.com/Salastil/moho/commit/46e3d7f9530fcb1f46fbcb2fad0260110d78b2a6
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Salastil/moho#140