Skip to content

Fix Wasm incompatibility in web error processing#1684

Open
brunovsiqueira wants to merge 1 commit intoRevenueCat:mainfrom
brunovsiqueira:fix/wasm-js-interop-runtime-check-1651
Open

Fix Wasm incompatibility in web error processing#1684
brunovsiqueira wants to merge 1 commit intoRevenueCat:mainfrom
brunovsiqueira:fix/wasm-js-interop-runtime-check-1651

Conversation

@brunovsiqueira
Copy link
Copy Markdown

@brunovsiqueira brunovsiqueira commented Mar 15, 2026

Fixes #1651

Description

The _processError method in purchases_flutter_web.dart uses error is JSObject, which triggers the invalid_runtime_check_with_js_interop_types lint. The is operator on JS interop types is unreliable under Wasm compilation because JS interop types are erased differently between JS and Wasm targets.

This replaces the runtime check with the Wasm-safe isA<JSObject>() method from dart:js_interop (available since Dart 3.4, and the project requires Dart >=3.6.0).

  • A description about what and why you are contributing, even if it's trivial.
  • The issue number(s) or PR number(s) in the description if you are contributing in response to those.
  • If applicable, unit tests.

Changes

lib/web/purchases_flutter_web.dart

  • Cast error to JSAny? before checking
  • Replace error is JSObject with jsAny.isA<JSObject>()
  • Extract jsObject via jsAny as JSObject after the isA confirmation
  • No new imports needed (dart:js_interop is already imported)
  • Identical runtime behavior to the original code

CHANGELOG.md

  • Added bugfix entry under 9.14.0

Test plan

  • dart format . — clean
  • flutter analyze lib — passes with no issues (the invalid_runtime_check_with_js_interop_types warning is gone)
  • flutter test — all 134 tests pass
  • cd revenuecat_examples/purchase_tester && flutter build web — web build verification
  • cd revenuecat_examples/purchase_tester && flutter build web --wasm — Wasm build verification
  • CI: bundle exec fastlane run_api_tests — no public API changes (requires CI environment)

Why no new unit tests

_processError is a private method that uses dart:js_interop types requiring a web runtime. The repo has no web-platform test infrastructure (flutter test --platform chrome), and the change is a mechanical replacement of one pattern with its Wasm-safe equivalent. flutter analyze statically catches the lint if it regresses. Adding web test infra would be out of scope for this bugfix.

@brunovsiqueira brunovsiqueira requested a review from a team as a code owner March 15, 2026 17:01
Replace `is JSObject` runtime check with Wasm-safe `isA<JSObject>()`
in `_processError`. The `is` operator on JS interop types is unreliable
under Wasm compilation due to type erasure differences between JS and
Wasm targets.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@brunovsiqueira brunovsiqueira force-pushed the fix/wasm-js-interop-runtime-check-1651 branch from d78f0e4 to 0f5743b Compare March 15, 2026 17:07
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.

Wasm Incompatability

1 participant