Skip to content

fix: [Flutter Web] TypeError JSArray #2224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

river2202
Copy link

@river2202 river2202 commented Apr 18, 2025

Submit a pull request

FYI, someone can forward this without me signing CLA

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

@river2202 river2202 mentioned this pull request Apr 18, 2025
1 task
@river2202 river2202 force-pushed the fix/flutter-web-type-error-js-array branch from e84160d to 9391452 Compare April 22, 2025 00:53
@xsahil03x xsahil03x requested a review from Copilot May 13, 2025 08:57
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request addresses a Flutter Web TypeError related to JSArray by refining error handling and ensuring proper typed list initializations.

  • Added a try-catch block with debug logging in channel_api.dart for queryChannels response processing
  • Updated several list spread operations to use explicit generic list declarations in channel.dart

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/stream_chat/lib/src/core/api/channel_api.dart Added error handling for queryChannels response, returning an empty QueryChannelsResponse on error
packages/stream_chat/lib/src/client/channel.dart Updated list initializations with explicit generic types to resolve potential JSArray issues

Comment on lines +86 to +88
} catch (e) {
debugPrint('queryChannels error: $e');
return QueryChannelsResponse.fromJson({});
Copy link
Preview

Copilot AI May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning an empty QueryChannelsResponse in the catch block may mask issues during JSON parsing. Consider handling the error more explicitly, such as propagating the error or providing a detailed error message.

Suggested change
} catch (e) {
debugPrint('queryChannels error: $e');
return QueryChannelsResponse.fromJson({});
} catch (e, stackTrace) {
debugPrint('queryChannels error: $e');
throw QueryChannelsException(
'Failed to parse QueryChannelsResponse: $e',
stackTrace,
);

Copilot uses AI. Check for mistakes.


// Remove quoted message reference from every message if available.
updatedMessages = [...updatedMessages].map((it) {
updatedMessages = <Message>[...updatedMessages].map((it) {
Copy link
Preview

Copilot AI May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mapping over the list returns an Iterable rather than a List. To ensure type consistency, consider appending .toList() after the map operation.

Copilot uses AI. Check for mistakes.

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.

1 participant