neil-morrison44 / pocket-sync

A GUI tool (Mac, Windows, Linux) for doing stuff with the Analogue Pocket
GNU Affero General Public License v3.0
670 stars 25 forks source link

Bug in Internet Archive Fetch with invalid parameters - Fetch: null undefined is not an object (evaluating 'i.filter') #244

Closed f00b4r0 closed 9 months ago

f00b4r0 commented 9 months ago

Describe the bug Pocket Sync becomes unusable if an invalid Internet Archive fetch is setup.

As soon as the Fetch section is opened and the remote fetch is "loaded", the software will error and all interface buttons yield the same error message (Fetch: null, Settings: null, Pocket Sync: null, etc - followed by the same backtrace).

Fetch: null
undefined is not an object (evaluating 'i.filter')
@tauri://localhost/assets/index-WJH2i5YW.js:4793:1956216
useMemo@tauri://localhost/assets/index-WJH2i5YW.js:38:83521
ATe@tauri://localhost/assets/index-WJH2i5YW.js:4793:1956210
_C@tauri://localhost/assets/index-WJH2i5YW.js:38:77192
Z4@tauri://localhost/assets/index-WJH2i5YW.js:40:129753
q4@tauri://localhost/assets/index-WJH2i5YW.js:40:125485
GW@tauri://localhost/assets/index-WJH2i5YW.js:40:125413
q1@tauri://localhost/assets/index-WJH2i5YW.js:40:125265
HE@tauri://localhost/assets/index-WJH2i5YW.js:40:121629
V4@tauri://localhost/assets/index-WJH2i5YW.js:40:120578
V4@[native code]
T@tauri://localhost/assets/index-WJH2i5YW.js:25:10734
K@tauri://localhost/assets/index-WJH2i5YW.js:25:11102

Clicking "Retry" changes the last 4 lines, subsequent clicks trigger no further changes:

Fetch: null
undefined is not an object (evaluating 'i.filter')
@tauri://localhost/assets/index-WJH2i5YW.js:4793:1956216
useMemo@tauri://localhost/assets/index-WJH2i5YW.js:38:83521
ATe@tauri://localhost/assets/index-WJH2i5YW.js:4793:1956210
_C@tauri://localhost/assets/index-WJH2i5YW.js:38:77192
Z4@tauri://localhost/assets/index-WJH2i5YW.js:40:129753
q4@tauri://localhost/assets/index-WJH2i5YW.js:40:125485
GW@tauri://localhost/assets/index-WJH2i5YW.js:40:125413
q1@tauri://localhost/assets/index-WJH2i5YW.js:40:125265
HE@tauri://localhost/assets/index-WJH2i5YW.js:40:121629
$3@tauri://localhost/assets/index-WJH2i5YW.js:40:122433
$3@[native code]
Hu@tauri://localhost/assets/index-WJH2i5YW.js:38:60932
@tauri://localhost/assets/index-WJH2i5YW.js:40:119958

To Reproduce Steps to reproduce the behaviour:

  1. Go to Fetch
  2. Click on Add new Fetch
  3. Select Internet Archive fetch
  4. enter random gibberish for the end of the url (e.g. 'sdfsdfsdf')
  5. select target folder
  6. click "Add Fetch"

Wait for "Loading..." to run in the Fetch list and observe the crash.

To recover from this situation (from the GUI): quit, restart Pocket Sync, click "Fetch" and immediately click "Remove" on the offending fetch before it has time to load. Pocket Sync may still crash once again but after quitting and restarting Pocket Sync once more the offending fetch will be gone and the crash will no longer occur.

Expected behaviour An error message can be reported and the fetch invalidated without crashing the entire software.

Logs The fetch is setup at 10:01:46

[2024-02-11][10:00:31][DEBUG][reqwest::connect] starting new connection: https://openfpga-cores-inventory.github.io/
[2024-02-11][10:01:46][DEBUG][pocket_sync] Command: save_file - /Volumes/UNTITLED/pocket-sync.json
[2024-02-11][10:01:46][DEBUG][pocket_sync] Command: file_exists - pocket-sync.json
[2024-02-11][10:01:46][DEBUG][pocket_sync] Command: file_exists - /
[2024-02-11][10:01:46][DEBUG][pocket_sync] Command: file_exists - pocket-sync.json
[2024-02-11][10:01:46][DEBUG][pocket_sync] Command: read_text_file - pocket-sync.json
[2024-02-11][10:01:46][DEBUG][reqwest::connect] starting new connection: https://archive.org/
[2024-02-11][10:01:49][DEBUG][pocket_sync] Command: walkdir_list_files - /Assets
[2024-02-11][10:01:49][DEBUG][pocket_sync] Command: file_exists - /Volumes/UNTITLED//Assets//gb/common/dmg_bios.bin
[2024-02-11][10:01:49][DEBUG][pocket_sync] Command: file_exists - /Volumes/UNTITLED//Assets//gb/common/gb_bios.bin
[2024-02-11][10:01:49][DEBUG][pocket_sync] Command: file_exists - /Volumes/UNTITLED//Assets//gb/common/Super Mario Land (World) (Rev A).gb
[2024-02-11][10:01:49][DEBUG][pocket_sync] Command: file_exists - /Volumes/UNTITLED//Assets//gba/common/gba_bios.bin
[2024-02-11][10:01:49][DEBUG][pocket_sync] Command: file_exists - /Volumes/UNTITLED//Assets//gbc/common/gbc_bios.bin
[2024-02-11][10:01:49][DEBUG][pocket_sync] Command: file_exists - /Volumes/UNTITLED//Assets//gg/common/Sonic The Hedgehog (Japan, Europe, Brazil) (En) (Rev 1).gg

After quitting Pocket Sync the following last line is output:

[2024-02-11][10:03:04][INFO][webview] Fetching Inventory

Desktop (please complete the following information):

Additional context There's also a window size / scrolling issue (buttons become unreachable) when setting up this bug that I will report separately (#245)

neil-morrison44 commented 9 months ago

Should be fairly simple to verify that there's an active archive at the address, and also handle when an archive starts 404ing later due to it being removed.

There's another fix for this that doesn't require fast clicking - the pocket-sync.json file contains a fetches array where they're stored on the device. Removing the invalid fetch from there would also fix it