{"slug": "paper-finder-a-free-ai-powered-research-tool-and-the-7-second-freeze-i-had-to", "title": "Paper Finder: A Free AI-Powered Research Tool and the 7-Second Freeze I Had to Debug", "summary": "A developer built Paper Finder, a free AI-powered research tool that searches arXiv, Semantic Scholar, and Crossref and re-ranks results using a browser-based AI model. The developer debugged a 7-second input freeze caused by synchronous WASM inference blocking the main thread, and resolved it by moving the model into a Web Worker.", "body_md": "I built [Paper Finder](https://paperfinder.dev), a free tool that searches arXiv, Semantic Scholar, and Crossref at once, then re-ranks the results by semantic relevance.\n\nThe ranking uses a small AI model that runs entirely in the browser, so there are no API costs or accounts. But it introduced a nasty bug: typing in the search box could freeze for up to seven seconds.\n\nPaper Finder initially sorted results by year. To improve relevance, I added `Xenova/all-MiniLM-L6-v2`\n\nthrough transformers.js. It embeds the query and each result, then ranks them using cosine similarity.\n\nThe results appeared before re-ranking began, so I assumed the AI work was safely happening \"in the background.\"\n\nThen a user sent me a Chrome DevTools trace showing 1,350.9 ms of input delay. My first thought was, \"That can't be the AI—it's async.\"\n\nI was wrong.\n\nI used Chrome's `PerformanceObserver`\n\nwith the `longtask`\n\nentry type, which reports tasks that block the main thread for more than 50 ms:\n\n``` js\nconst observer = new PerformanceObserver((list) => {\n  for (const entry of list.getEntries()) {\n    console.log(`Blocked for ${entry.duration}ms`);\n  }\n});\n\nobserver.observe({ entryTypes: [\"longtask\"] });\n```\n\nAfter clearing the browser's model cache and running a fresh search, I saw this:\n\n```\n{ duration: 7079, start: 13735 }\n```\n\nOne task had blocked the main thread for 7,079 ms. During that time, the page couldn't process typing, clicks, or anything else.\n\n`await`\n\ndidn't help\nThe embedding call used `await`\n\n, but that doesn't move work off the main thread. It only yields while waiting for genuinely asynchronous work, such as network requests or timers.\n\nWASM inference is synchronous CPU work. Wrapping it in a Promise changes how you receive the result, not where the computation runs. The model initialization and inference were still competing with rendering and input on the main thread.\n\nI moved the model into a dedicated Web Worker:\n\n``` js\n// embedder.worker.ts\nself.onmessage = async (event) => {\n  const extractor = await getExtractor();\n\n  const output = await extractor(event.data.texts, {\n    pooling: \"mean\",\n    normalize: true,\n  });\n\n  self.postMessage({ vectors: /* ... */ });\n};\n```\n\nThe main thread now sends text to the worker and waits for the vectors to come back. The public interface didn't need to change—a Worker-backed Promise looks the same to callers.\n\nAfter repeating the cold-cache test:\n\n```\nlongtasks: []\n```\n\nZero long tasks, and the search box remained responsive throughout.\n\nThe main lesson: `await`\n\ndoes not mean \"won't block the main thread.\" For client-side ML or any other CPU-heavy work, use a Web Worker from the start.\n\nThe source is [on GitHub](https://github.com/emmanuel-adu/paper-finder), and the live app is at [paperfinder.dev](https://paperfinder.dev).", "url": "https://wpnews.pro/news/paper-finder-a-free-ai-powered-research-tool-and-the-7-second-freeze-i-had-to", "canonical_source": "https://dev.to/emmanueladu/paper-finder-a-free-ai-powered-research-tool-and-the-7-second-freeze-i-had-to-debug-a2l", "published_at": "2026-07-29 02:40:52+00:00", "updated_at": "2026-07-29 03:30:37.606711+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "machine-learning", "large-language-models"], "entities": ["Paper Finder", "arXiv", "Semantic Scholar", "Crossref", "Xenova", "all-MiniLM-L6-v2", "transformers.js", "GitHub"], "alternates": {"html": "https://wpnews.pro/news/paper-finder-a-free-ai-powered-research-tool-and-the-7-second-freeze-i-had-to", "markdown": "https://wpnews.pro/news/paper-finder-a-free-ai-powered-research-tool-and-the-7-second-freeze-i-had-to.md", "text": "https://wpnews.pro/news/paper-finder-a-free-ai-powered-research-tool-and-the-7-second-freeze-i-had-to.txt", "jsonld": "https://wpnews.pro/news/paper-finder-a-free-ai-powered-research-tool-and-the-7-second-freeze-i-had-to.jsonld"}}