Novik / ruTorrent

Yet another web front-end for rTorrent
Other
1.98k stars 409 forks source link

JS error: [MyIP/rutorrent/js/webui.js?v=4210 : 1554] Uncaught TypeError: Cannot read properties of undefined (reading 'state') #2642

Closed antonio8909 closed 3 weeks ago

antonio8909 commented 2 months ago

Please complete the following tasks.

Tell us about your environment

Web Browser: Microsoft Edge 122.0.2365.80 ruTorrent: v4.2.9 PHP: 8.1.2-1ubuntu2.14 (cli) (built: Aug 18 2023 11:41:11) (NTS) OS: Ubuntu 22.04.4 LTS

Tell us how you installed ruTorrent

Via swizzin community edition

Describe the bug

When I try to delete an specific RSS feed it says JS error: [MyIP/rutorrent/js/webui.js?v=4210 : 1554] Uncaught TypeError: Cannot read properties of undefined (reading 'state') and I can't delete it. I have others RSS feeds that can be deleted without issue. I'm hitting this issue on a specific RSS.

Steps to reproduce

  1. Go to the Feeds section and find the RSS Feed to delete
  2. Right-click to get the menu to edit or delete the feed
  3. The error appears

Expected behavior

Being able to access to the menu to edit and delete the feed

Additional context

No response

antonio8909 commented 2 months ago

Uncaught TypeError: Cannot read properties of undefined (reading 'state') from TypeError: Cannot read properties of undefined (reading 'state') at Object.isTorrentCommandEnabled (https://MyIP/rutorrent/js/webui.js?v=4210:1554:39) at theWebUI.isTorrentCommandEnabled (:2419:41) at theWebUI.isTorrentCommandEnabled (:5573:38) at theWebUI.createMenu (:5536:11) at theWebUI.createMenu (:5659:21) at theWebUI.createMenu (:6010:21) at theWebUI.createMenu (:6512:21) at theWebUI.createMenu (:7542:21) at theWebUI.createMenu (:8405:21) at theWebUI.createMenu (:8745:21)

TrimmingFool commented 2 months ago

@antonio8909 Do you have an idea why this is only a problem for one specific RSS feed? I don't know how to reproduce this.

My guess would be, that for some reason there is id === null here:

https://github.com/Novik/ruTorrent/blob/2d67a00b4fde90b4a652c130ed76ac2fc4383fb3/plugins/rss/init.js#L468-L477

If you are able, it would be great if you could use the debugger to say if the id is null or some rss-url for this call.

You could either set a breakpoint on exceptions: https://developer.chrome.com/docs/devtools/javascript/breakpoints#exceptions and print out the hash value, when breaking here: https://github.com/Novik/ruTorrent/blob/2d67a00b4fde90b4a652c130ed76ac2fc4383fb3/js/webui.js#L1551-L1554 OR https://developer.chrome.com/docs/devtools/search Go to rss createMenu function (by searching for 'context menu for rss item' via Ctrl-Shift-F) and set a break point on the plugin.createMenu.call(theWebUI, e, id); line (and print out the id value)

antonio8909 commented 2 months ago

Hi @TrimmingFool

I don't know the reason why it's failing just in that RSS. I'd try on older ruTorrent releases in another server (3.10, for example) and it works fine :/

I hope this helps!! If you need the full hash line where the tracker's RSS link is shown, please do tell me how can I share it on a private way as it can contain sensitive/personal info of my account

image

Thank you very much

TrimmingFool commented 2 months ago

Sorry for the delay. Actually, the assumption which is broken here is that all links are in theWebUI.rssItems. @stickz So, if we want to keep the workaround with the regex for now, it should replace the if (id in this.rssItems) { check. (I'm not sure but the check if (id in theWebUI.getTable('rss').rowSel) { might be a better workaround.)

@antonio8909 That is exactly what I wanted, thank you! I would still like to find the actual bug. Could you please provide the output of this array expression (during the breakpoint in the console):

[
hash in theWebUI.rssItems,
theWebUI.getTable('rss').rowSel[hash],
hash in theWebUI.getTable('rss').rowIDs,
hash === theWebUI.getTable('rss').getFirstSelected() ,
theWebUI.getTable('rss').getFirstSelected() == null,
Object.keys(theWebUI.rssItems).length,
theWebUI.getTable('rss').rowIDs.length
]
antonio8909 commented 2 months ago

I'm so sorry @TrimmingFool

I saw yesterday that the hotfix was available and I quickly applied it to manage again my RSS feeds so I can't reproduce again the bug.

My deepest apologies.

TrimmingFool commented 2 months ago

@antonio8909 It's not a big deal. Maybe the root cause for this will disappear with https://github.com/Novik/ruTorrent/issues/2637 when the table uses guid instead of href.