Skip to content

Conversation

@SunsetTechuila
Copy link
Member

partially _fixes #6554

Test URLs

https://github.com/refined-github/refined-github/issues -> issue -> go back

Screenshot

@SunsetTechuila SunsetTechuila marked this pull request as ready for review January 20, 2026 15:29
@fregante
Copy link
Member

 one-event 4.4.0 published 🎉

@fregante fregante added the bug label Jan 22, 2026
function linkifyIssue(paragraph: HTMLParagraphElement): void {
// Already linkified
if (elementExists('a', paragraph)) {
logError(new Error(`${paragraph.textContent} is already linkified`));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this? This change seems to suggest that features will now run multiple times on the same view.

The PR also seems to add a listener for the "render" but not for the "unload", causing all features to potentially be inited multiple times. What happens if I call observe('a');observe('a') for example? I think it's deduplicated almost correctly, but then does the abort signal work well?

The alternative could be to also unload the features on "soft nav react bye" if it exists, but then most likely we'll get flickering from features coming and going.

I think a quick way to test whether the PR works as-is would be to open the Task Manager and go back and forth between React tabs. If the page doesn't leak and slow down considerably after 50 back and forth, then we should be good.

Copy link
Member Author

@SunsetTechuila SunsetTechuila Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR also seems to add a listener for the "render" but not for the "unload", causing all features to potentially be inited multiple times.

No, features are unloaded correctly, you don't need to listen for any new events

document.addEventListener('turbo:before-fetch-request', unloadAll); // Clicks
document.addEventListener('turbo:visit', unloadAll); // Back/forward button

Copy link
Member Author

@SunsetTechuila SunsetTechuila Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally you won't see this error, but it can happen if you try hard enough

To reproduce:

  1. Open a repo's issue list
  2. Open an issue
  3. Click the Issues navbar tab
  4. Hit the browser back button to return to the issue

Timings are important - you've to be fast, but not too fast. Usually takes me 2-3 tries. Сan't say for sure yet what exactly is happening and why

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, features are unloaded correctly, you don't need to listen for any new events

document.addEventListener('turbo:before-fetch-request', unloadAll); // Clicks
document.addEventListener('turbo:visit', unloadAll); // Back/forward button

This is no longer true (but certainly was)

Copy link
Member Author

@SunsetTechuila SunsetTechuila Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose our only option is to unload the features on the navigate "push"/"traverse" events

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Navigation API should now be available cross browser, I'm just afraid it fires too often. Worth a check too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked to see if we could hook some function to emit custom navigation events, but none of the breakpoints I set on navigation-related functions were hit. I might be missing something, though. If you want to check for yourself, the ReactAppElement source is a good starting point.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but none of the breakpoints I set on navigation-related functions were hit

Managed to hit them - the functions are being used, just not when navigating from the issue list to an issue page

}
});
} while (await oneEvent(document, 'turbo:render'));
} while (await oneEvent(document, ['turbo:render', 'soft-nav:react-done']));
Copy link
Member Author

@SunsetTechuila SunsetTechuila Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unlike soft-nav:render, soft-nav:react-done is fired when user navigates the session history too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants