Skip to content

fix: abort request when timeout occurs#1440

Merged
wendux merged 1 commit intocfug:developfrom
amondnet:abort-connection
Mar 29, 2022
Merged

fix: abort request when timeout occurs#1440
wendux merged 1 commit intocfug:developfrom
amondnet:abort-connection

Conversation

@amondnet
Copy link
Copy Markdown
Contributor

@amondnet amondnet commented Mar 7, 2022

New Pull Request Checklist

  • I have read the Documentation
  • I have searched for a similar pull request in the project and found none
  • I have updated this branch with the latest develop to avoid conflicts (via merge from master or rebase)
  • I have added the required tests to prove the fix/feature I am adding
  • I have updated the documentation (if necessary)
  • I have run the tests and they pass

This merge request fixes / refers to the following issues: ...

Pull Request Description

browser_adapter abort request when timeout occurs.

https://github.com/flutterchina/dio/blob/6d04ec95d951bdecd19a2939d94de217d2d1ff7d/dio/lib/src/adapters/browser_adapter.dart#L78
https://github.com/flutterchina/dio/blob/6d04ec95d951bdecd19a2939d94de217d2d1ff7d/dio/lib/src/adapters/browser_adapter.dart#L102
https://github.com/flutterchina/dio/blob/6d04ec95d951bdecd19a2939d94de217d2d1ff7d/dio/lib/src/adapters/browser_adapter.dart#L128

io_adapter detach socket when receiveTimeout is occurs.
https://github.com/flutterchina/dio/blob/6d04ec95d951bdecd19a2939d94de217d2d1ff7d/dio/lib/src/adapters/io_adapter.dart#L119

But io_adapter does not abort the request when connectTimeout and sendTimeout are occurs. And we use socket.destroy() instead of socket.close().

https://api.dart.dev/stable/2.16.1/dart-io/Socket/close.html

Close the target consumer.

NOTE: Writes to the IOSink may be buffered, and may not be flushed by a call to close(). To flush all buffered writes, call flush() before calling close().

https://api.dart.dev/stable/2.16.1/dart-io/Socket/destroy.html

Destroys the socket in both directions.

Calling destroy will make the send a close event on the stream and will no longer react on data being piped to it.

Call close (inherited from IOSink) to only close the Socket for sending data.

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.

2 participants