fix: truncate input before sanitization to fix 816s JS test timeout#50810
Conversation
…ocessing of large inputs The "should truncate long content" test was timing out at ~816 seconds because sanitizeContentCore ran all expensive operations (hardenUnicodeText, neutralizeAllMentions, applyToNonCodeRegions, applyURLSanitizationPolicy, etc.) on the full 600,000-character input before truncating at line 1382. Fix: add an early applyTruncation call at the start of sanitizeContentCore so oversized inputs are cut down to maxLength (default 524,288) before any other processing begins. A second truncation pass is still applied later (after normalization may reduce length by stripping invisible chars). This drops the test from ~816s to under 1s. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Triage SummaryCategory: bug (perf fix) | Risk: low | Priority score: 55/100 Score breakdown: impact 25 + urgency 15 + quality 15 Recommended action: Small, well-scoped fix (5 additions, 1 file) that resolves an 816s test timeout by truncating input before expensive sanitization passes. No CI data available yet; no reviews posted. Low blast radius, high test-suite value.
|
|
Warning Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding. What happenedThe threat detection engine failed to produce results. Review the workflow run logs for details. Hey One small thing to consider for completeness:
If you'd like to add test coverage, here's a prompt: Otherwise, this is ready to go! 🚀
|
sanitizeContentCorewas running all expensive operations — Unicode normalization, entity decoding, homoglyph mapping, 3×applyToNonCodeRegionspasses, mention neutralization, URL policy — on the full raw input before truncating. A 600k-char input caused the"should truncate long content"test to hang for 816 seconds.Change
applyTruncationto the top ofsanitizeContentCore, before any other processing. Inputs exceedingmaxLength(default 524,288) are cut immediately.Result:
compute_text.test.cjs(51 tests) drops from 816,365 ms (1 failed) → 387 ms (all pass).