Skip to content

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
mainfrom
devin/1782156218-improve-error-handling
Open

Improve error handling: fix silent failures, add error logging and network error handlers#674
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782156218-improve-error-handling

Conversation

@devin-ai-integration

Copy link
Copy Markdown

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: The else if branch had the identical condition as the if (request.isSuccess === true), making the auth-failure alert unreachable. Restructured to if (isSuccess) { ... } else { ... }.

  • leetcode.jsstartUploadCountDown(): if ((uploadState.uploading = true)) used assignment = instead of comparison ===, so the timeout always triggered markUploadFailed().

Silent failures now logged:

  • upload() / update(): non-200 GitHub API responses are now logged with status + body. JSON.parse is wrapped in try/catch. XHR error event listeners added.
  • uploadGit(): warns when token, hook, or mode is missing instead of silently returning.
  • findCode(): logs error when submission URL is missing or fetch fails.
  • authorize.js: parseAccessCode alerts user on OAuth denial, requestToken guards against missing access_token in response, finish handles non-200 from /user endpoint. All three methods now have network error handlers and propagate error details to background.js.
  • popup.js: handles unexpected HTTP status codes and network errors on token validation.
  • welcome.js: JSON.parse wrapped in try/catch for createRepo/linkRepo with 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 prevent TypeError on missing elements.

Link to Devin session: https://app.devin.ai/sessions/5f210014ba32407f91e54574f0a93808
Requested by: @QasimWani

…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>
@QasimWani QasimWani self-assigned this Jun 22, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant