Skip to content

fix: Prevent TypeError when sendMessage resolves undefined - #161

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/undefined-response-typeerror
Open

fix: Prevent TypeError when sendMessage resolves undefined#161
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/undefined-response-typeerror

Conversation

@sentry

@sentry sentry Bot commented Aug 20, 2026

Copy link
Copy Markdown

This PR addresses a TypeError: Cannot read properties of undefined (reading 'ok') that occurs in getComponents and getFlags within src/content/github/common/fetchers.ts.

The root cause is that browser.runtime.sendMessage can resolve with undefined when the background service worker's message handler (e.g., listComponents or listFlags) rejects (for instance, due to a network error or unhandled exception during an API call). Chrome MV3's behavior in this scenario is to resolve sendMessage with undefined rather than propagating the rejection.

To fix this, optional chaining (?.ok) has been added when accessing the ok property of the response object. This ensures that if response is undefined, the expression gracefully evaluates to undefined (or false in the ternary), preventing the TypeError and allowing the code to fall back to an empty array.

Fixes BROWSER-EXTENSION-S9

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 91 bytes (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
codecov-browser-extension-array-push 660.55kB 91 bytes (0.01%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: codecov-browser-extension-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
background.js 89 bytes 207.75kB 0.04%
githubFile.js 2 bytes 11.47kB 0.02%

Files in githubFile.js:

  • ./src/content/github/common/fetchers.ts → Total Size: 2.44kB

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.

0 participants