I have a pretty straightforward setup. On my articles#index page I have my list of articles. When clicking publish/unpublish the article gets updated and the row in the index gets replaced via turbo_stream.
However, if the user clicks to quickly before the request is finished, the turbo_stream gets canceled and the row never replaced.
In the console I see the following error:
Uncaught (in promise) DOMException: The user aborted a request.
Promise.then (async)
window.fetch @ includes.js?v=35a79b300ab5afa978cb59af0b05e059:964
perform @ admin.debug-3ea5ea7a581c7452d3b10d756060d869744c99c5ec054c08bbfa89ca816ac826.js:27351
await in perform (async)
start @ admin.debug-3ea5ea7a581c7452d3b10d756060d869744c99c5ec054c08bbfa89ca816ac826.js:27564
submitForm @ admin.debug-3ea5ea7a581c7452d3b10d756060d869744c99c5ec054c08bbfa89ca816ac826.js:29101
formSubmitted @ admin.debug-3ea5ea7a581c7452d3b10d756060d869744c99c5ec054c08bbfa89ca816ac826.js:29810
FormSubmitObserver.submitBubbled @ admin.debug-3ea5ea7a581c7452d3b10d756060d869744c99c5ec054c08bbfa89ca816ac826.js:27763
Is this expected behavior with a turbo_stream?
Button in View
= button_to article.published? ? "Unpublish" : "Publish", admin_article_publish_path(article), method: :patch, class: class_names("action-button": !article.published?, "secondary-button": article.published?)
Controller
class Admin::Articles::PublishesController < Admin::BaseController
def update
@article = Article.find params[:article_id]
@article.toggle(:published)
@article.save
respond_to do |format|
format.turbo_stream
end
end
update.turbo_stream.haml
= turbo_stream.replace dom_id(@article) do
= render partial: "admin/articles/article", locals: { article: @article }