-
Notifications
You must be signed in to change notification settings - Fork 146
Description
Issue 1 Title:
No Retry Mechanism for Failed or Rate-Limited API Requests
Issue:
When the Groq API returns an error (especially 429 Too Many Requests), the extension immediately fails without retrying.
Cause:
There is no retry logic implemented in the fetch request handling, especially for transient or rate-limiting errors.
How it Affects:
Users may see a failure message even when a retry could have resolved the issue. This can lead to frustration and make the extension seem unreliable.
Suggested Fix:
Add a basic retry mechanism that retries the request 1–2 times with a short delay if a 429 error occurs.
Solution:
async function callGroqAPI(payload, retries = 2) {
try {
const res = await fetch(...);
if (res.status === 429 && retries > 0) {
await new Promise(r => setTimeout(r, 1000));
return await callGroqAPI(payload, retries - 1);
}
return res;
} catch (err) {
throw err;
}
}
Benefits:
• Handles temporary API limits more gracefully
• Improves user experience by reducing unnecessary failures
• Makes the extension more reliable in real-world usage
Issue 2 Title:
Context Menu Actions May Fail If Page is Not Fully Ready
Issue:
Sometimes when users right-click selected text quickly after page load, the context menu action fails or does nothing.
Cause:
The content script may not be injected or fully initialized when the action is triggered.
How it Affects:
Users experience random failures or inconsistent behavior when using the translation or explanation features, especially on heavy pages.
Suggested Fix:
Ensure that the content script runs after the page is idle, and gracefully handle message delivery failures.
Solution:
• In manifest.json, set content script to run at document_idle:
"run_at": "document_idle"
In content.js, add a fallback handler:
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
try {
// your existing logic
} catch (err) {
sendResponse({ error: 'Content script failed to process the request.' });
}
});
Benefits:
• Improves reliability across all websites
• Reduces the chance of “nothing happens” errors
• Provides better resilience on slow or complex web pages