Skip to content

link previews: scan only the links tried (a message of bare https:// took 1.6 GB) - #107

Open
JSKitty wants to merge 1 commit into
masterfrom
fix/link-preview-scan
Open

JSKitty wants to merge 1 commit into
masterfrom
fix/link-preview-scan

Conversation

@JSKitty

@JSKitty JSKitty commented Nov 19, 2026

Copy link
Copy Markdown

What

fetch_msg_metadata collected every HTTPS link in a message before it tried the first three. A run of bare https:// with no delimiter names one link per byte offset of 8, and each one runs to the end of the text. A 160 KB message of https:// repeated is 20,000 copies, 1.6 GB in all. The scan runs when the message is shown with link previews on, so a peer could send it. On a relay that accepts large events, a few hundred KB is enough to run the machine out of memory.

extract_https_urls now takes a max and stops there. It is the same scan, and the first three links are the same as before. This applies to Tauri (src-tauri/src/util.rs, its one caller in message/mod.rs) and Vector Web (crates/vector-web/src/chat_ops.rs).

Verification

  • Old against new on 50,000 random inputs (schemes, delimiters, trailing punctuation, multi-byte text, nested links), first three compared: 0 differences.
  • 20,000 × https://: 1.6 GB and 49 s (debug) before, under 1 ms now.
  • I have not built Tauri or the wasm worker on this box, so the change relies on CI to compile. The diff is a while let turned into a bounded loop with let … else, and a new argument at each call site.

The GPUI port carries the same fix (crates/vector-gpui/src/backend/unfurl.rs on gpui, a lazy iterator), with the equivalence test in its suite.


Generated by Claude Code

Every link was collected before the first three were tried, and a run of
bare https:// names one link per byte, each running to the end of the
text: 160 KB of it is 20,000 copies, 1.6 GB in all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qq6RetJnzXvEeXAvSsgvs1
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

JSKitty commented Nov 19, 2026

Copy link
Copy Markdown
Author

The red claude check is the claude-code-action review job, not a build or a test. It stopped at setup because the repository has no ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN secret ("Environment variable validation failed"). It fails the same way on every pull request that opens (#106 too), so it isn't caused by this change. src-tauri, vector-core and CodeQL are green.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants