Skip to content

non GET requests (PUT, POST, DELETE) requests stay with pending status and never "finish" #8509

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

Closed
ydolzhenko opened this issue Nov 5, 2024 · 10 comments
Labels
P2 important to work on, but not at the top of the work list. screen: network Issues with the Network screen.

Comments

@ydolzhenko
Copy link

ydolzhenko commented Nov 5, 2024

Basically all non-GET requests that return empty body (just 200 OK) get stuck with pending status and never end - while in fact they're working as expected.

The ones that return with any body content are being displayed fine.


DevTools version: 2.37.3
IDE: Android-Studio
Connected Device:
CPU / OS: x64 (64 bit) ios
Connected app type: Flutter native (debug build)
Dart Version: 3.5.4
Flutter Version: 3.24.4 / stable
Framework / Engine: 603104015d / db49896cf2

@kenzieschmoll kenzieschmoll added screen: network Issues with the Network screen. P2 important to work on, but not at the top of the work list. labels Nov 5, 2024
@kenzieschmoll
Copy link
Member

Can you provide a minimal repro of the case you are talking about so that we can reproduce the issue?

@ydolzhenko
Copy link
Author

I can't right now, I'm on the road, but it's easily reproducible - basically all POST/PUT/DELETE (and I suggest GET, but empty GET wouldn't make sense so I don't have it) with empty bodies render as Pending.

@JulianSchmidtZollsoft
Copy link

We are experiencing the same behaviour. All requests that resolve with status 204 (and have an empty Response body) are still marked as "Pending" and are missing the "Request"- and "Response"-Tab.

Bildschirmfoto 2024-11-21 um 14 27 30

@duytq94
Copy link

duytq94 commented Jan 20, 2025

I have the same issue (currently I'm on ver 3.27.1)

Image

@srawlins
Copy link
Contributor

@ydolzhenko @duytq94 @JulianSchmidtZollsoft sorry for the delay. I can reproduce this, but I'd like some more details, if you can:

  • What HTTP client is making these requests? I imagine something like dart:io's HttpClient, or package:http, or package:dio...
  • What HTTP server is making the responses (with no bodies)? I am testing with dart:io's HttpServer, but I'm hoping the bug is not in HttpServer.

I suspect this is a bug in dart:io. Something like dart-lang/sdk#39548 or dart-lang/sdk#45679 or dart-lang/sdk#30842. I'm investigating in there at the moment.

@JulianSchmidtZollsoft
Copy link

@srawlins
We are using package:http on the Client. The Server is written in Java.

@srawlins
Copy link
Contributor

Thanks! In the meantime I've developed a new theory that there is a race condition in the profiling code, in dart:io. When there is no response body, _HttpProfileData.finishResponse() seems to be called before _HttpProfileData.startResponse() 🙃.

@ydolzhenko
Copy link
Author

@srawlins , same as @JulianSchmidtZollsoft - package:http on the client and a jvm/tomcat server.

@srawlins
Copy link
Contributor

I see indeed that _HttpProfileData.finishResponse() is called before _HttpProfileData.startResponse(). I think this is just a result of microtask scheduling; when the response has no body, _incoming.dataDone completes before _httpRequest._responseCompleter.

Since startResponse is responsible for setting responseInProgress to true, the call to finishResponse short circuit returns immediately. We therefore don't finish the response timeline, or log the end time, etc.

copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Mar 17, 2025
…esponse

Fixes flutter/devtools#8509

From my research into the bug:

> I see indeed that `_HttpProfileData.finishResponse()` is called before `_HttpProfileData.startResponse()`. I think this is just a result of microtask scheduling; when the response has no body, `_incoming.dataDone` completes before `_httpRequest._responseCompleter`.

> Since `startResponse` is responsible for setting `responseInProgress` to `true`, the call to `finishResponse` short circuit returns immediately. We therefore don't finish the response timeline, or log the end time, etc.

The fix here does not rely on microtask organization, which I think would be fragile. Instead, we don't listen to the `dataDone` future
until we've logged the start of the response.

Change-Id: Ib735742b297a261e6566ae8caf9eac0d71fc8fdb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415140
Reviewed-by: Ben Konyi <[email protected]>
Commit-Queue: Samuel Rawlins <[email protected]>
@srawlins
Copy link
Contributor

This should be fixed with https://dart-review.googlesource.com/c/sdk/+/415140. The fix will first appear in Dart 3.8 stable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 important to work on, but not at the top of the work list. screen: network Issues with the Network screen.
Projects
None yet
Development

No branches or pull requests

5 participants