violentmonkey: [BUG] GM storage is not updating after page refresh in beta 2.15.8

Continuation from #1793

Sequence of actions:

  1. Userscript is installed in a dev environment through a local webserver (I’m having this problem with my userscript BetterYTM)
  2. music.youtube.com is opened
  3. GM storage already contains the key bytm-installed from previous tests so no welcome menu pops up
  4. All values in GM storage are cleared through a menu command using GM.listValues() and GM.deleteValue()
  5. Listing all values in GM storage using a menu command yields no entries
  6. The page is reloaded
  7. The welcome menu still doesn’t pop up. GM.getValue("bytm-installed") returns { ... }. Running the “list values” menu command yields the entries that should’ve previously been deleted

The inverse can sometimes happen where GM storage gets “stuck” on empty values, so that no matter how many times GM.setValue("bytm-installed", "{ ... }") is run, the value of GM.getValue("bytm-installed") will always be undefined

This problem does not occur on beta v2.15.5 and I haven’t been able to reproduce it with a static script that was solely created for testing this issue so either this only happens with local development or with scripts that have at some point been installed already.
I tested renaming the name and namespace in the header to no avail.

I’ve recorded a video to help explain it: https://youtu.be/qcx-ryh4mJo
Timestamps:

  • 0:00 script is installed, just got updated by the file being changed on the dev server
  • 0:04 page is reloaded
  • 0:08 initial value of bytm-installed (see sequence step 3)
  • 0:11 all values are deleted using this menu command (see sequence step 4)
  • 0:16 page is reloaded, welcome menu should be shown
  • 0:20 GM.getValue() here should return undefined since the storage was just cleared but returns old data (timestamp is exactly the same as before)
  • 0:26 storage is again deleted and listed to show that no values were found (sequence step 4 and 5)
  • 0:37 page is reloaded, welcome menu should be shown once again
  • 0:41 again, listing the values shows that bytm-installed is still present and contains the same exact timestamp

Note: the values starting with _uu can be ignored for this example, though any updates to them are also discarded after page reload.

Problem:

See above.
GM storage gets “stuck” on a previous set of values and doesn’t apply any changes so they are persisted through page reloads.

Expected result:

GM storage should always persist.

Devtools console contents:

See video.

Environment:

  • OS: MacOS 13.5.2
  • Browser: Firefox Developer Edition 119.0b5
  • Violentmonkey Version: Beta v2.15.8

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 22 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Now I can’t replicate it anymore… I have a general idea of what’s wrong though.