Default home feed sort causes page to auto-refresh
If I turn on the default home feed sort option, various pages will randomly refresh. I can't isolate anything specific that triggers it, I can do an action and it refreshes, then I do the same thing again and it doesn't.
- It randomly refreshes just scrolling down the feed
- It refreshes sometimes as soon as it's done loading
- It refreshes most times when I search for something
- It refreshes most times when I open the reddit enhancer extension menu.
- It's not just limited to the feed, individual post pages will refresh too, often as soon as they are done loading, or when I click the image in an image post
It's hard to completely confirm, but as far as I can tell all the issues stop when I turn off the default home feed sort.
The default comment sort option doesn't seem to affect this.
Yeah, the same thing happens with subreddits aswell. I believe reddit defaults back to "sort by best" pretty often and if you have another option set, the addon has to refresh the page to the new option. That's why the problem stops if you disable it in the addon. I may be wrong though.
Seems to be a duplication of #98...
@nDrew0 absolutely hit the bullseye here, and I kind of mentioned the reasons we chose to refresh the page when implementing Default Home Feed Sort Option and Default Feed Sort Option in #98 (TL;DR: either the extension redirects you to the sorted URL, which is often faster, or waits a few seconds before the sort menu appears in view and toggles it for you). (2) and (3) are intended behaviours, it takes some time for the browser to execute RE’s redirection requests.
It should only look at the URL and refresh when the feed page first loads + after the duration you set under Override Default Sort Option though, so if you find RE randomly refreshing the page as you scroll down or open the RE menu, this is extremely concerning. My wild guess is that the extension is crashing (?)
@Joelacus and I will take a look at and attempt to correct this and #98 as soon as we can.
You’re welcome to view the code for changing the feed sorting option here:
https://github.com/joelacus/RedditEnhancer/blob/main/src-webpack/src/common/content_first/functions/default_sort_option.js#L35
On 2 May 2025, at 20:28, Andrew @.***> wrote:
nDrew0 left a comment (joelacus/RedditEnhancer#163) Yeah, the same thing happens with subreddits aswell. I believe reddit defaults back to "sort by best" pretty often and if you have another option set, the addon has to refresh the page to the new option. That's why the problem stops if you disable it in the addon. I may be wrong though. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Is it possible to see the reason for it refreshing? Either a crash or it being triggered? I carefully watched the chrome console when it happened and there were no indicators I could see that points to one or the other.
Hi. There aren't any console logs for the default sort option at the moment, but that is something we could add to help diagnose this. A few people have mentioned this issue, but I don't understand what is causing it exactly, the function runs when the page is first loaded, so randomly happening as you're scrolling is odd.
I use Firefox on Linux, and have never experienced this issue, I don't know if that makes a difference at all. Perhaps Chrome unloads the extension from memory periodically to reduce system resources (not that the extension uses much), and then when the extension is loaded again and it sees a URL without the chosen sort option, it refreshes the page? Opening the RE settings menu would also cause the extension to load if it has crashed or been unloaded, and thus could trigger the function to redirect to the chosen sort option. I don't know, it's just a guess atm.
I'd be happy to install a dev build if you want to add some logging.
@Watchful1 @nDrew0 Is it okay if you both can share your current extension configuration (Settings, Backup) so that we can load into ours and try to reproduce the problem? Also I think @joelacus added some logging for the sorting functions in 1.17.0 so you can take a look (right-click the page and select Inspect, switch to the Console tab, and search for content.js to filter the browser and Reddit's logs)
I am on 1.17.0. I've attached my settings backup.
The only error from content.js seems to be this.
content.js:1 Uncaught TypeError: Cannot read properties of null (reading 'shadowRoot')
at eo (content.js:1:191277)
at content.js:1:190883
at NodeList.forEach (<anonymous>)
at content.js:1:190870
but I'm happy to provide the full console log if you think that would be useful.
On Chrome, the symptoms are much more recognisable when I also have Default Comment Sort Option activated; the page reloaded for me after applying the new sort option and I pressed the Back button on the post. After that, when I opened the extension menu, the page reloaded once more. No logs are pointing towards the theory of RE crashing...
What's more intriguing is that all of these don't happen on Firefox at all. Perhaps a rewrite of the sort functions is necessary :(
Thanks, I've got it installed and I'll let you know if I hit any reloads.
I'm getting errors. These are showing up in the chrome extensions page and include the minified json which I've attached.
Uncaught TypeError: Cannot read properties of null (reading 'shadowRoot')
https://gist.github.com/Watchful1/5bd5fcea26bb7a7dc899aa5ddf50b9b5
Function enableDefaultHomeFeedSortOption not found
https://gist.github.com/Watchful1/248b73d0b6060b5bcb2778bc4b0f93fb
Some features seem to be working and some aren't. I'll switch back to the release version for now.
Ah, I should've sent you the non JS minified version instead. You can skip the shadowRoot error, that's probably for a different function since defaultSortOption isn't modifying any shadow DOMs (might have to later).
Function enableDefaultHomeFeedSortOption not found is interesting though. Do you have Default Home Feed Sort option turned on or off while testing the dev build I sent, or have you tried turning it off and on again? Did other sorting features work when you had this error?
I might be able to send a new development build later today or tomorrow.
I had default home feed sort turn on, got the error, turned it off and the error stopped. With it on, none of the sorts seemed to work. I didn't use it very much once I turned it off, so I couldn't say for sure. Happy to try again if you want.
Can you try this build and see if it's better now? The code in this build isn't minified, so it should be easier to spot the errors.
No reloads within a few minutes of using it. I have all the default sorts turned on.
I'll followup tomorrow with any other issues I find.
Ah, spoke too soon. Here are the errors
Error handling response: TypeError: Cannot read properties of undefined (reading 'x')
popup/popup.html
popup/popup.js:9811 (anonymous function)
Middle line highlighted
// Scroll To Next Root Comment Position X
chrome.storage.sync.get(['scrollToNextRootCommentPosition'], function (result) {
const valueX = result.scrollToNextRootCommentPosition.x;
if (typeof valueX == 'undefined' || valueX === '-1') {
document.querySelector('#input-scroll-to-root-comment-position-x').value = -1;
Next error
Uncaught TypeError: Cannot read properties of null (reading 'shadowRoot')
content.js:18401 (anonymous function)
again middle line highlighted
// Recent Section Event Listener
setTimeout(() => {
const recentSection = document.querySelector('reddit-recent-pages').shadowRoot.querySelector('faceplate-expandable-section-helper');
if (recentSection && addRecentSectionListener) {
recentSection.addEventListener('click', function (e) {
The first one occurred twice, the second 5 times.
Oh, these are from some other functions. I’ll address them. Do the sorts work?
On 10 Jun 2025, at 08:30, Watchful1 @.***> wrote:
Watchful1 left a comment (joelacus/RedditEnhancer#163) Ah, spoke too soon. Here are the errors Error handling response: TypeError: Cannot read properties of undefined (reading 'x') popup/popup.html popup/popup.js:9811 (anonymous function)
Middle line highlighted // Scroll To Next Root Comment Position X chrome.storage.sync.get(['scrollToNextRootCommentPosition'], function (result) { const valueX = result.scrollToNextRootCommentPosition.x; if (typeof valueX == 'undefined' || valueX === '-1') { document.querySelector('#input-scroll-to-root-comment-position-x').value = -1;
Next error Uncaught TypeError: Cannot read properties of null (reading 'shadowRoot') content.js:18401 (anonymous function)
again middle line highlighted // Recent Section Event Listener setTimeout(() => { const recentSection = document.querySelector('reddit-recent-pages').shadowRoot.querySelector('faceplate-expandable-section-helper'); if (recentSection && addRecentSectionListener) { recentSection.addEventListener('click', function (e) {
The first one occurred twice, the second 5 times. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
Sorry for the slow response. No, they don't seem to be working at all. In fact I don't think anything in the extension is working.
Same error
Error handling response: TypeError: Cannot read properties of undefined (reading 'x')
// Scroll To Next Root Comment Position X
chrome.storage.sync.get(['scrollToNextRootCommentPosition'], function (result) {
const valueX = result.scrollToNextRootCommentPosition.x || 'undefined';
if (typeof valueX == 'undefined' || valueX === '-1') {
document.querySelector('#input-scroll-to-root-comment-position-x').value = -1;
interesting there was a similar error but the function was slightly different
Error handling response: TypeError: Cannot read properties of undefined (reading 'y')
// Scroll To Next Root Comment Position Y
chrome.storage.sync.get(['scrollToNextRootCommentPosition'], function (result) {
const valueY = result.scrollToNextRootCommentPosition.y;
if (typeof valueY == 'undefined' || valueY === '-1') {
document.querySelector('#input-scroll-to-root-comment-position-y').value = -1;
and another shadowRoot with two different stack traces
Uncaught TypeError: Cannot read properties of null (reading 'shadowRoot')
postCreditBar.lastElementChild.insertBefore(menu, postCreditBar.lastElementChild.lastElementChild);
const postMenu = post.querySelector('shreddit-post-overflow-menu');
if (postMenu.shadowRoot) {
postMenu.shadowRoot.querySelectorAll('faceplate-menu > li > div:not(.hidden)').forEach((item) => {
menu.appendChild(item);
if (document.querySelector('[routename="post_page"]')) {
attachMenu(document.querySelector('shreddit-post'));
} else {
document.querySelectorAll('shreddit-post').forEach((post) => {
attachMenu(post);
});
Thanks for your continued efforts on this!
I've just published version 2.0.0 with some fixes; you should get the update within a few days. If you continue to encounter any errors, let us know and I'll reopen this issue, thanks.
Unfortunately I'm still getting refreshes with the new version. I've even tried turning off the feed and comment sort options and they are still happening. I don't see anything relevant in the log when it does.
It's hard to tell, but anecdotally I think they are more frequent than before.
@Watchful1 I think I've found the root cause of this issue. v2.0.1 is being released soon, let me know if the page is still reloading randomly, when opening the extension popup or clicking on the expandos after you update to the new version.
In the meantime you can work around this by turning on Just Open the Image under the Media section.
@joelacus In the background script there's disableJustOpenTheImage() which removes the redirection rulesets and reloads the page. You set it to be called every time when Just Open the Image in disabled, which is... every time the background script is called. There was absolutely no problems with the feed sorting functions or #160 :)
@bmndc Oh, it's been like that for ages, I've never experienced any of these page refreshes myself. Maybe because I'm using Linux? idk. If the background script/extension is reloaded, would that clear any active rulesets anyway, so there is no need to ensure the ruleset is disabled? I wasn't sure if the browser remembered rulesets or not. I can easily remove the disableJustOpenTheImage() function when the background script starts if that's what causing the page refreshes.
Edit: I've pushed this change to dev c4306ef
@joelacus Or maybe because you've been using Just Open The Images :)
I only briefly read the docs on declarativeNetRequests APIs, but I think Chrome retains the rulesets across sessions (so across reloads?) unless you manually disable it or the extension gets updated. As such I just replace the tabs.reload() with a simple alert telling the user to manually reload.
@bmndc Ah yeah, I forgot I did that. I'll remove tabs.reload().
Unless you have anything else to change, I'll publish version 2.0.1 tonight.