Improve error handling: fix silent failures, add error logging and network error handlers#674
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Conversation
…twork error handlers
- background.js: Fix unreachable error branch (else-if had identical condition
as if, making the auth failure alert dead code). Restructure to properly
handle isSuccess=false.
- leetcode.js:
- upload()/update(): Log errors for non-200 GitHub API responses instead of
silently swallowing them. Add try/catch around JSON.parse. Add XHR error
event listeners for network failures.
- uploadGit(): Log warnings when token, hook, or commit mode is missing
instead of silently doing nothing.
- findCode(): Add error handling for missing submission URL, non-200
responses, and network errors.
- startUploadCountDown(): Fix bug using assignment (=) instead of
comparison (===) in conditional check.
- authorize.js:
- parseAccessCode(): Log and alert user on OAuth errors instead of silently
closing tab. Guard against missing code in URL.
- requestToken(): Guard against missing access_token in response. Add
network error handler. Include error details in failure messages.
- finish(): Handle non-200 from GitHub user API and parse errors instead of
silently hanging. Add network error handler.
- popup.js: Add handling for unexpected HTTP status codes and network errors
on the GitHub token validation request.
- welcome.js: Wrap JSON.parse in try/catch for createRepo and linkRepo to
prevent uncaught exceptions on malformed responses. Add XHR error event
listeners with user-visible error messages.
- gfg.js: Add null-safety guards on all DOM queries (findGfgLanguage,
findTitle, findDifficulty, getProblemStatement, submit button, output
element) to prevent uncaught TypeError on missing elements.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Systematic audit and fix of error handling across all JS files. The codebase had many places where errors were silently swallowed — failed API calls produced no logs, missing config caused silent no-ops, and network errors were completely unhandled.
Bugs fixed:
background.js— dead code: Theelse ifbranch had the identical condition as theif(request.isSuccess === true), making the auth-failure alert unreachable. Restructured toif (isSuccess) { ... } else { ... }.leetcode.js—startUploadCountDown():if ((uploadState.uploading = true))used assignment=instead of comparison===, so the timeout always triggeredmarkUploadFailed().Silent failures now logged:
upload()/update(): non-200 GitHub API responses are now logged with status + body.JSON.parseis wrapped in try/catch. XHRerrorevent listeners added.uploadGit(): warns whentoken,hook, ormodeis missing instead of silently returning.findCode(): logs error when submission URL is missing or fetch fails.authorize.js:parseAccessCodealerts user on OAuth denial,requestTokenguards against missingaccess_tokenin response,finishhandles non-200 from/userendpoint. All three methods now have network error handlers and propagateerrordetails tobackground.js.popup.js: handles unexpected HTTP status codes and network errors on token validation.welcome.js:JSON.parsewrapped in try/catch forcreateRepo/linkRepowith user-visible error messages. XHR error listeners added.gfg.js: null-safety on all DOM queries (findGfgLanguage,findTitle,findDifficulty,getProblemStatement, submit button, output element) to preventTypeErroron missing elements.Link to Devin session: https://app.devin.ai/sessions/5f210014ba32407f91e54574f0a93808
Requested by: @QasimWani