-
Notifications
You must be signed in to change notification settings - Fork 429
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
Include url in turbo:before-fetch-request
event
#289
Include url in turbo:before-fetch-request
event
#289
Conversation
@@ -71,6 +71,14 @@ export class VisitTests extends TurboDriveTestCase { | |||
this.resetRequestInterceptor() | |||
} | |||
|
|||
async "test turbo:before-fetch-request event.detail"() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am getting a timeout error when I run the whole suite, but everything seems to work if I run this specific test in isolation (by adding intern.configure({ grep: /turbo:before/ })
in runner.js
).
It's strange since it's basically identical to the request interceptor test.
× firefox on linux 5.10.0-0.bpo.5-amd64 - VisitTests - turbo:before-fetch-request event.detail (2.5s)
TimeoutError: Timeout reached on firefox on linux 5.10.0-0.bpo.5-amd64 - VisitTests - turbo:before-fetch-request event.detail#
at Timeout._onTimeout @ src/lib/Test.ts:226:24
at ontimeout @ timers.js:436:11
at tryOnTimeout @ timers.js:300:5
at listOnTimeout @ timers.js:263:5
at Timer.processTimers @ timers.js:223:10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are seeing the same on #299. Only for Firefox. Odd. Please do investigate!
@ctrochalakis could you please resolve merge conflicts? The |
TurboDriveTestCase maintains a eventLogChannel that acts as a cursor for the page's window.eventLogs array. Before every test the eventLogChannel is drained by reading all events and its internal index (cursor) is updated accordingly. The race was happening when we changed the page location and not blocking on it: the eventLogChannel was draining the previous page bumping its internal index. After the page was reload that index was out of sync since the new page had an new, empty eventLogs array. Order of events * async location change * draining eventLogChannel on the previous page * actual location change * eventLogChannel is out-of-sync This is was fixed as part of hotwired#289
9e67f91
to
33170b3
Compare
@ctrochalakis nice catch with visits tests race condition! 👍 |
33170b3
to
09b846a
Compare
TurboDriveTestCase maintains a eventLogChannel that acts as a cursor for the page's window.eventLogs array. Before every test the eventLogChannel is drained by reading all events and its internal index (cursor) is updated accordingly. The race was happening when we changed the page location and not blocking on it: the eventLogChannel was draining the previous page bumping its internal index. After the page was reload that index was out of sync since the new page had an new, empty eventLogs array. Order of events * async location change * draining eventLogChannel on the previous page * actual location change * eventLogChannel is out-of-sync This is was fixed as part of #289
Hello all and thank you for Turbo.
Although the
turbo:before-fetch-request
event includes the request'sfetchOptions
(method, headers, etc), it doesn't include the URL itself. With this patch applied you can access it withevent.detail.url
.If it gets accepted I can send a PR to add a reference to the
events
documentation in https://github.com/hotwired/turbo-site/.