extensions icon indicating copy to clipboard operation
extensions copied to clipboard

Update tldr extension

Open 0xdhrv opened this issue 2 months ago • 4 comments

Description

Fixes https://github.com/raycast/extensions/issues/23848

Checklist

0xdhrv avatar Dec 22 '25 15:12 0xdhrv

Thank you for your contribution! :tada:

🔔 @pomdtr @ridemountainpig @0xdhrv you might want to have a look.

You can use this guide to learn how to check out the Pull Request locally in order to test it.

📋 Quick checkout commands
BRANCH="ext/tldr"
FORK_URL="https://github.com/0xdhrv/raycast-extensions.git"
EXTENSION_NAME="tldr"
REPO_NAME="raycast-extensions"

git clone -n --depth=1 --filter=tree:0 -b $BRANCH $FORK_URL
cd $REPO_NAME
git sparse-checkout set --no-cone "extensions/$EXTENSION_NAME"
git checkout
cd "extensions/$EXTENSION_NAME"
npm install && npm run dev

Due to our current reduced availability, the initial review may take up to 10-15 business days.

raycastbot avatar Dec 22 '25 15:12 raycastbot

@greptileai, could you please do a fresh review of this PR?

0xdhrv avatar Dec 22 '25 15:12 0xdhrv

Greptile Summary

This PR fixes a critical memory issue (JS heap out of memory) that prevented the TLDR extension from working on Windows. The root cause was the old implementation downloading and extracting a large ZIP file containing all TLDR pages, then using globby to scan thousands of files simultaneously, which exceeded the JavaScript heap limit.

Key Changes

  • Replaced ZIP download approach with GitHub API: Instead of downloading/extracting a ~50MB ZIP and scanning all files at once, the new implementation uses GitHub's tree API to list files, then fetches individual pages from raw.githubusercontent.com
  • Removed memory-intensive dependencies: Eliminated adm-zip and globby packages which were causing the heap overflow
  • Progressive loading with batching: Fetches pages in batches of 50 to prevent memory spikes, with exponential backoff retry logic
  • Smart caching: Uses Raycast's LocalStorage for efficient 7-day caching instead of file system operations
  • Improved UX: Added progress indicators during cache updates and platform filtering dropdown

How It Fixes the Issue

The original implementation tried to process all ~9,000 TLDR pages at once by extracting a ZIP file and running file system glob operations, which exhausted available memory. The new approach:

  1. Makes one API call to get the file tree
  2. Fetches content progressively in batches from CDN (no rate limits)
  3. Processes pages incrementally, preventing memory buildup

This architectural change eliminates the memory bottleneck while providing better performance and user experience.

Confidence Score: 5/5

  • This PR is safe to merge - it fixes a critical production issue with a well-architected solution
  • The implementation successfully addresses the reported memory issue by replacing the problematic ZIP extraction approach with an efficient GitHub API solution. The code includes proper error handling, retry logic, batching to prevent memory spikes, and maintains backward compatibility. The architectural change is sound and eliminates the root cause.
  • No files require special attention

Important Files Changed

Filename Overview
extensions/tldr/src/search.tsx Complete rewrite from file-system based approach to GitHub API approach - memory efficient and fixes heap overflow issue
extensions/tldr/package.json Removed adm-zip and globby dependencies that were causing memory issues
extensions/tldr/CHANGELOG.md Added changelog entry for the fix with proper placeholder format

greptile-apps[bot] avatar Dec 22 '25 16:12 greptile-apps[bot]

@greptileai, could you please do a fresh review of this PR?

0xdhrv avatar Dec 22 '25 18:12 0xdhrv

Published to the Raycast Store: https://raycast.com/pomdtr/tldr

github-actions[bot] avatar Jan 05 '26 10:01 github-actions[bot]

:tada: :tada: :tada:

We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag.

raycastbot avatar Jan 05 '26 10:01 raycastbot