Skip to content

fix: handle undefined MessageEvent in postMessageStream#402

Merged
chaitanyapotti merged 1 commit into
masterfrom
fix/postMessageStream-non-browser
Jul 21, 2026
Merged

fix: handle undefined MessageEvent in postMessageStream#402
chaitanyapotti merged 1 commit into
masterfrom
fix/postMessageStream-non-browser

Conversation

@tuna1207

@tuna1207 tuna1207 commented Jul 21, 2026

Copy link
Copy Markdown
Member

Jira Link

Description

  • Guard MessageEvent.prototype access in PostMessageStream so importing @web3auth/auth does not throw in non-browser runtimes (e.g. Hermes/React Native) where MessageEvent is undefined.
  • The package root re-exports PostMessageStream via the jrpc barrel, so this was an import-time failure even when consumers never instantiate the class.

How has this been tested?

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • My code follows the code style of this project. (run lint)
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Note

Low Risk
Small defensive guard at module init with unchanged browser behavior when MessageEvent is present; limited to JRPC postMessage stream setup.

Overview
Fixes a module-load crash when MessageEvent is missing (e.g. Hermes/React Native). postMessageStream no longer reads MessageEvent.prototype at import time; it only resolves the source/origin property getters when MessageEvent exists, and the existing _onMessageHandler fallbacks to event.origin / event.source still apply when those getters are absent.

Adds a test that deletes global MessageEvent and asserts import("../src/jrpc") still exposes PostMessageStream.

Reviewed by Cursor Bugbot for commit 2cf89be. Bugbot is set up for automated code reviews on this repo. Configure here.

@tuna1207
tuna1207 requested a review from a team as a code owner July 21, 2026 08:49
@chaitanyapotti
chaitanyapotti merged commit b26637a into master Jul 21, 2026
5 checks passed
@chaitanyapotti
chaitanyapotti deleted the fix/postMessageStream-non-browser branch July 21, 2026 09:08
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.

2 participants