hotwired / turbo

The speed of a single-page web application without having to write any JavaScript
https://turbo.hotwired.dev
MIT License
6.73k stars 428 forks source link

Uncaught (in promise) error when clicking links whilst a visit is in-flight #716

Open domchristie opened 2 years ago

domchristie commented 2 years ago

This is most noticeable when pausing rendering for animations: if your click a link then tap another whilst that one is in-flight, an Uncaught (in promise) error is thrown, originating here:

https://github.com/hotwired/turbo/blob/2332d3d0153886ff0c616198e377687a76ac5226/src/core/drive/visit.ts#L188 ~I think this.resolvingFunctions is undefined~

In 7.2.0-beta.2 this results in console errors. In 7.2.0-rc.1, rendering fails.

Looks like it might be something to do with: https://github.com/hotwired/turbo/pull/650? /cc @seanpdoyle

kevinmcconnell commented 2 years ago

This sounds related to the problem reported in #706 (see https://github.com/hotwired/turbo/issues/706#issuecomment-1235188847)

domchristie commented 2 years ago

@kevinmcconnell well spotted, thanks. Yes, this looks related. I'll keep this open in case the rendering issue differs.

seanpdoyle commented 2 years ago

@domchristie thank you for opening this issue. Is the issue reproducible in https://github.com/hotwired/turbo/releases/tag/v7.2.0-rc.2? I have a hunch it could be related to https://github.com/hotwired/turbo/pull/715.

domchristie commented 2 years ago

@seanpdoyle thanks! Rendering is fixed in 7.2.0-rc.2 👍 but the error is still thrown. Perhaps we can catch the cancel rejection if the visit is cancelled by a subsequent visit?

domchristie commented 2 years ago

Rendering is fixed in 7.2.0-rc.2

Mostly! I can still reproduce this occasionally, but it's intermittent, and I can't quite pin down the conditions

martinzamuner commented 2 years ago

I can confirm that the error is still being thrown in 7.2.0-rc.2.

In my case it has to do with visits that return a Turbo Stream. I can reproduce it in the test server:

  1. Open http://localhost:9000/src/tests/fixtures/visit.html
  2. Click Stream link with ?key=value
  3. Click any other link

This results in the following error: Uncaught (in promise) undefined. It doesn't seem to have any other consequence. Everything works great despite the error.

martinzamuner commented 2 years ago

I'm not seeing the error anymore after 1ec72ac3236038af50a0010f0821e0664eeac087 👍.