tools icon indicating copy to clipboard operation
tools copied to clipboard

TypeError on every Incoming Message

Open sakchhams opened this issue 6 months ago • 2 comments

Every incoming message throws a TypeError.

Error Deatails.

dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 117:77  tear
operations.dart:117
dart-sdk/lib/_internal/js_dev_runtime/patch/js_allow_interop_patch.dart 224:27    _callDartFunctionFast1
js_allow_interop_patch.dart:224
DartError: TypeError: Instance of '_JsonMap': type '_JsonMap' is not a subtype of type 'String'
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:3       throw_
errors.dart:266
dart-sdk/lib/_internal/js_dev_runtime/private/profile.dart 117:39                 _asString

Flutter Doctor

[✓] Flutter (Channel stable, 3.32.4, on Ubuntu 25.04 6.14.0-28-generic, locale en_US.UTF-8)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/to/linux-android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[!] Android Studio (not installed)
[✓] VS Code (version unknown)
    ✗ Unable to determine VS Code version.
[✓] Connected device (2 available)
[✓] Network resources

! Doctor found issues in 2 categories.

Likely Cause

jsonDecode below produces a _JsonMap, which throws an error when being casted as a String.

// lib/client/sse_client.dart

  void _onIncomingMessage(Event message) {
    var decoded =
        jsonDecode(((message as MessageEvent).data as JSString).toDart);
    _incomingController.add(decoded as String);
  }

sakchhams avatar Aug 20 '25 04:08 sakchhams

Thanks for the report! Can you provide the version of sse that you're using, and, do you have any info on the contents of the data before we try and convert it?

cc @bkonyi

devoncarew avatar Sep 16 '25 17:09 devoncarew

Package Version:

sse: ^4.1.8

Message Payload (copied from Chrome Devtools)

{"WeatherInfo":["2025-09-17T09:22:41","CXBPStation09",96.94999694824219]}

sakchhams avatar Sep 17 '25 03:09 sakchhams