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

Wrap dio_link executeDioRequest in try-catch block #472

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amritnew
Copy link

@amritnew amritnew commented Oct 11, 2024

The request function has a return type of Stream<Response>. As a result, the catch block will use Stream.error() to asynchronously propagate the exception.

request function is having return type Stream<Response>. Hence catch block will yield Stream.error() to send exception asynchronously
@knaeckeKami
Copy link
Collaborator

can you show in code how this would actually result in a different behavior? from what i see, this behaves exactly as before

@anshul-arora
Copy link

@knaeckeKami
The above fix seems to fix the issue i was facing with bad network connectivity

What i see from the code is that _executeDioRequest method was throwing an exception, which was not being catched and yielded by the request method

thanks @amritnew for the fix

Fatal Exception: FlutterError LinkException(DioException [connection error]: The connection errored: Failed host lookup: 'xxx.xxx.xx.com' This indicates an error which most likely cannot be solved by the library. Error: SocketException: Failed host lookup: 'xxx.xxx.xx.com' (OS Error: nodename nor servname provided, or not known, errno = 8), #0 DioMixin.fetch (package:dio/src/dio_mixin.dart:520) <asynchronous suspension> #1 DioLink._executeDioRequest (package:gql_dio_link/src/dio_link.dart:198) <asynchronous suspension> #2 DioLink.request (package:gql_dio_link/src/dio_link.dart:71) <asynchronous suspension> )

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.

3 participants