Duplicate requests result in blank screen

I am working with turbo-ios talking to a rails app.

In the iOS app I have a link that results in a modal and then within that modal when I follow a link (that is meant to push a new view on the modal navigation stack) I wind up with a blank page.

I started with the turbo-ios demo app, and added a path property that tells it to not dismiss the current modal and to visit using the modal session

My rails app gets 2 requests. The first one in the rails log says it is successful, but in the safari console that is debugging iOS it appears aborted:

By watching the logs in Xcode I can see that the visitDelegate of the WebViewBridge becomes nil and no longer receives callbacks (which I think is the ultimate cause of the blank screen I have)

I can make it “work” by making visitDelegate a strong instead of weak reference

var visitDelegate: WebViewVisitDelegate!

I can also seem to fix it by changing the order of operations in the session because it prevents this race condition: Session.swift +64

  let visit = makeVisit(for: visitable, options: options ?? VisitOptions())
  currentVisit?.cancel()
  visit.delegate = self
  visit.start()
        
  currentVisit = visit

This sounds like a similar issue to the one I had here: If a form submission redirects, the target page is rendered twice · Issue #12 · hotwired/turbo-ios · GitHub. @zachwaugh had a fix here.

I extracted a fix for the demo into [demo] Always call `session.visit` with options by ghiculescu · Pull Request #18 · hotwired/turbo-ios · GitHub, but basically can you try calling session.visit(visitable, options: options) instead of just session.visit(visitable).