Skip to content
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

Reconnecting with a server error does not work #37

Open
wildCherryTO opened this issue Dec 6, 2024 · 0 comments
Open

Reconnecting with a server error does not work #37

wildCherryTO opened this issue Dec 6, 2024 · 0 comments

Comments

@wildCherryTO
Copy link

wildCherryTO commented Dec 6, 2024

At the moment when the server returns an error, reconnection does not work. The problem is in the code section (see below).
The problem is with "return" after calling onError.

File: client.dart

  if (data.statusCode < 200 || data.statusCode >= 300) {
    String responseBody = await data.stream.bytesToString();
    if (onError != null) {
      Map<String, dynamic>? errorDetails;
      try {
        errorDetails = jsonDecode(responseBody);
      } catch (e) {
        errorDetails = {'rawBody': responseBody};
      }

      onError(
        EventFluxException(
          statusCode: data.statusCode,
          reasonPhrase: data.reasonPhrase,
          message: errorDetails.toString().isEmpty
              ? data.reasonPhrase
              : errorDetails.toString(),
        ),
      );
    }
    return;
  }

  if (autoReconnect && data.statusCode != 200) {
    _attemptReconnectIfNeeded(
      _isExplicitDisconnect,
      autoReconnect,
      type,
      url,
      header,
      onSuccessCallback,
      onError: onError,
      onConnectionClose: onConnectionClose,
      httpClient: httpClient,
      body: body,
      files: files,
      multipartRequest: multipartRequest,
    );
    return;
  }
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

No branches or pull requests

1 participant