-
Notifications
You must be signed in to change notification settings - Fork 433
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
await
for FetchRequest
delegate to handle response
#1039
base: main
Are you sure you want to change the base?
Conversation
I'm hopeful that this resolves the underlying problems mentioned by #884. I'm not sure how to add test coverage for this. With TypeScript, we'd be able to enforce the In the absence of that type checking, I'd really appreciate some guidance on how to add coverage to the test suite to guard against future regressions. |
2a7c917
to
d2478b5
Compare
I've added a comment on a suggested tweak which, in addition to the work you've done here, seems to resolve a related but different issue I've been having where the turbo-frame busy attribute is removed prior to the response body being downloaded and the frame being rendered, and there can be significant delay between this when there is a high latency connection and/or a large response body for the request. I'm not quite sure on the best approach to test this in this project because my initial thought was to assert the timing/ordering of related events and DOM mutations to be as expected - but it doesn't seem trivial with the helper methods currently provided since these behaviours are tracked separately. |
0b64bb1
to
b714f1f
Compare
36a565d
to
88c76e1
Compare
I am seeing a similar problem as @armstrjare. I have tested your update but it does not solve the issue for me. The busy attribute still is reset too early. I am using a form to update a turbo-frame like this: <form name="filter" method="get" data-turbo-frame="skill-results" class="mb-6">
<input type="text" id="search" x-on:input.debounce="$event.target.form.requestSubmit()" placeholder="Suchen" name="SearchText" value="">
</form>
<turbo-frame id="skill-results" src="https://localhost:5001/Skills?SearchText=" complete="">
</turbo-frame> The busy and aria-busy attributes are reset, when the response returns (before it is downloaded). It can be followed when throttling the network connection. I suspect that, additionally to your fixes, also in frame_controller.js |
Closes [hotwired#884] Despite the fact that `Visit` and `FrameController` are `FetchRequest` delegate classes that implement their delegate methods asynchronously on success ([Visit.requestSucceededWithResponse][] and [FrameController.requestSucceededWithResponse][]) and on failure ([Visit.requestFailedWithResponse][]) and [FrameController.requestFailedWithResponse][]), the `async FetchRequest.receive` method doesn't use the `await` keyword to wait for those delegates to finish handling their callbacks. This commit adds those `await` clauses. [Visit.requestSucceededWithResponse]: https://github.com/hotwired/turbo/blob/c207f5b25758e4a084e8ae42e49712b91cf37114/src/core/drive/visit.js#L297 [FrameController.requestSucceededWithResponse]: https://github.com/hotwired/turbo/blob/c207f5b25758e4a084e8ae42e49712b91cf37114/src/core/frames/frame_controller.js#L210 [Visit.requestFailedWithResponse]: https://github.com/hotwired/turbo/blob/c207f5b25758e4a084e8ae42e49712b91cf37114/src/core/drive/visit.js#L311 [FrameController.requestFailedWithResponse]: https://github.com/hotwired/turbo/blob/c207f5b25758e4a084e8ae42e49712b91cf37114/src/core/frames/frame_controller.js#L215 [hotwired#884]: hotwired#884
Closes #884
Despite the fact that
Visit
andFrameController
areFetchRequest
delegate classes that implement their delegate methods asynchronously on success (Visit.requestSucceededWithResponse and FrameController.requestSucceededWithResponse) and on failure (Visit.requestFailedWithResponse) andFrameController.requestFailedWithResponse), the
async FetchRequest.receive
method doesn't use theawait
keyword to wait for those delegates to finish handling their callbacks.This commit adds those
await
clauses.