Skip to content

Fix error handling and null pointer issues#20240

Closed
hobostay wants to merge 1 commit intoanomalyco:devfrom
hobostay:fix/silent-error-handling
Closed

Fix error handling and null pointer issues#20240
hobostay wants to merge 1 commit intoanomalyco:devfrom
hobostay:fix/silent-error-handling

Conversation

@hobostay
Copy link
Copy Markdown
Contributor

Summary

This PR fixes several error handling and null pointer issues that could cause silent failures or confusing runtime errors:

1. Silent error handling in global/index.ts

  • Issue: Empty catch block at line 52 silently swallowed cache cleanup errors
  • Fix: Added console.warn to log cache cleanup failures while continuing execution
  • Impact: Users will now see warning messages when cache cleanup fails, aiding debugging

2. Unsafe non-null assertion in provider/provider.ts

  • Issue: Line 1375 used ! non-null assertion without checking if find() returned undefined
  • Fix: Added explicit check and throw descriptive error if no "create" function is found
  • Impact: Better error message when provider module is malformed

3. Missing error handling in util/rpc.ts

  • Issue: The listen() function had no error handling for JSON parse errors or unknown methods
  • Fix: Added try-catch with proper error responses
  • Impact: RPC failures now return structured error responses instead of crashing

Test Plan

  • Code compiles without errors
  • All three issues are reproducible edge cases that are now handled gracefully

Screenshots

N/A

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

- Fix silent error handling in global/index.ts: log cache cleanup failures instead of swallowing them
- Fix unsafe non-null assertion in provider.ts: check if create function exists before accessing
- Add error handling to rpc.ts listen: handle JSON parse errors and unknown methods gracefully

These changes improve robustness and provide better error messages for debugging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 31, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title Fix error handling and null pointer issues doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

PR #11723: "fix: replace non-null assertions on find() with proper null checks"

The other results returned are PR #20240 itself (the current PR) and unrelated PRs about providers, memory leaks, and environment handling.

Conclusion: While PR #11723 shares a similar theme (fixing non-null assertions), the searches indicate PR #20240 appears to be addressing unique issues in specific files (global/index.ts, provider/provider.ts, util/rpc.ts) that don't have exact duplicates in currently open PRs.

No duplicate PRs found

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 31, 2026
@github-actions github-actions bot closed this Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant