fix(models-dev): prevent OOM crash on first launch#26781
fix(models-dev): prevent OOM crash on first launch#26781raycastbot merged 3 commits intoraycast:mainfrom
Conversation
- chore: ignore local debug files - fix: replace useCachedPromise with direct fetch to prevent OOM on first launch - Pull contributions
|
Thank you for the update! 🎉 We're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 10-15 business days. |
Greptile SummaryThis PR fixes a JS heap out-of-memory crash on first launch by replacing Key changes:
The implementation is logically sound. Two minor style nits: a placeholder Confidence Score: 5/5Safe to merge — all remaining findings are P2 style nits with no impact on correctness or behavior. The core logic is correct: the stale-while-revalidate semantics are preserved, error handling is appropriate, the No files require special attention. Important Files Changed
Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/models-dev/src/hooks/useModelsData.ts
Line: 13-14
Comment:
**Placeholder issue URL not updated**
The comment references `issues/XXX` which is a placeholder. Based on the PR description, the actual filed issue is `https://github.com/raycast/utils/issues/65`. This should be updated to point to the real issue for future maintainers.
```suggestion
* Uses direct fetch + Cache API instead of useCachedPromise to avoid
* memory spikes during fresh cache population. See:
* https://github.com/raycast/utils/issues/65
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/models-dev/src/hooks/useModelsData.ts
Line: 29-42
Comment:
**Redundant `setIsLoading(true)` call**
`isLoading` is already initialized to `!data` on line 29, so when `shouldRevalidate` is `false` (i.e. `data` is `null`), `isLoading` is already `true`. The `setIsLoading(true)` call inside the `if (!shouldRevalidate)` block is a no-op on first render and triggers an unnecessary re-render in React StrictMode (where the effect body runs twice).
```suggestion
const [isLoading, setIsLoading] = useState(!data);
const fetchedRef = useRef(false);
useEffect(() => {
// Already have cached data or already fetching
if (fetchedRef.current) return;
fetchedRef.current = true;
// If we have cached data, still revalidate in background
const shouldRevalidate = !!data;
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "Update models-dev extension" | Re-trigger Greptile |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
@0xdhrv @pernielsentikaer This one should be relatively straightforward. |
pernielsentikaer
left a comment
There was a problem hiding this comment.
Looks good to me, approved 🔥
|
Published to the Raycast Store: |
|
🎉 🎉 🎉 We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag. |
Summary
Fixes JS heap out of memory crash that occurs when opening the extension for the first time (empty cache).
Problem
useCachedPromiseuses ~4x more memory than direct fetch when populating an empty cache. For our dataset (~1.6 MB JSON, ~4,100 models), this caused the worker to exceed its memory limit and crash before rendering.This only affected first-time users or users who cleared their cache—subsequent launches worked fine.
Solution
Replaced
useCachedPromisewith directfetch+ Raycast'sCacheAPI. This:@raycast/utilsdependency (no longer needed)Related issue filed: raycast/utils#67
Checklist
npm run buildand tested this distribution build in Raycastassetsfolder are used by the extension itselfREADMEare placed outside of themetadatafolder