Stylus: Stylus is broken in the last Chrome canary

Created on 26 Oct 2018  Â·  39Comments  Â·  Source: openstyles/stylus

  • Browser: Google Chrome 72.0.3592.0 (Official Build) canary (64-bit)
  • Operating System: Windows 7 x64

Styles list in the manage.html is empty. There is an error in the console:

Uncaught (in promise) TypeError: Cannot read property 'name' of null
    at sorter.sort.styles.styles.map.style (manage.js:122)
    at Array.map (<anonymous>)
    at showStyles (manage.js:120)
    at Promise.all.then.args (manage.js:39)

The same error after an attempt to create and save a new style and go back to manage page. The style is not shown, the list is still empty.

external

Most helpful comment

Same issue here, after the update all my styIes in IndexedDB had a value of "null" however I was able to manually recover all of my lost styles by combing through the "000003.log" file located in AppData\Local\Google\Chrome Dev\User Data\Default\IndexedDB\chrome-extension_clngdbkpkpeebahjckkjfobafhncgmne_0.indexeddb.leveldb\ as it had not been wiped by the recent Canary update and contains readable CSS information.

All 39 comments

Error in the "Inspect views - background page":

Uncaught (in promise) TypeError: Cannot read property 'id' of null
    at dbExec.then.event (storage.js:179)

@Mottie I think we have to investigate why there is a null value inside the array to fix this bug.

@vsemozhetbyt Have you done something before the manager becomes empty?

+1
same here with chrome 72.0.3592.0 canary 64bit

@eight04 No, nothing at all. Canary has just updated and stylus has broken.

Open manage.html and try executing these commands in the dev console:

  1. BG.dbExec - this should report a function name, which should be dbExecIndexedDB or dbExecChromeStorage.
  2. copy(BG.cachedStyles.list) - this would copy all styles to the clipboard. It would also help if you can post them here.

@eight04

> BG.dbExec
< Æ’ dbExecIndexedDB(method, ...args) {
  return new Promise((resolve, reject) => {
    Object.assign(indexedDB.open('stylish', 2), {
      onsuccess(event) {
        const database = event.target.result;…
> copy(BG.cachedStyles.list)
< undefined

Copied BG.cachedStyles.list (the first 4 null seems to be my disappeared styles, the 5th object seems to be the last attempt to save a new style which is not shown in the list though):

[
  null,
  null,
  null,
  null,
  {
    "enabled": true,
    "updateUrl": null,
    "md5Url": null,
    "url": null,
    "originalMd5": null,
    "installDate": 1540555811467,
    "name": "global",
    "sections": [
      {
        "code": ":link, :link * {color: blue !important;}\n:visited, :visited * {color: red !important;}\n\n:link img {outline: 1px solid white !important;}\n:visited img {outline: 1px solid red !important;}\n\n:focus {outline: 1px solid blue !important;}\n",
        "urls": [],
        "urlPrefixes": [],
        "domains": [],
        "regexps": []
      }
    ],
    "id": 14
  }
]

I've opened manage.html and cleared the IndexedDB and the Local Storage in the DevTools Application tab. Then I've managed to create and save my styles. Now everything is OK.

Same problem here. Executing the commands said above gives me:

> BG.dbExec
< Æ’ dbExecIndexedDB(method, ...args) {
  return new Promise((resolve, reject) => {
    Object.assign(indexedDB.open('stylish', 2), {
      onsuccess(event) {
        const database = event.target.result;…
> copy(BG.cachedStyles.list)
< undefined
[
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null
]

To be clear: I had to manually recreate all my styles. It seems they were lost in an unrecoverable way if I am not mistaken. If you find the cause, maybe it is worth to report to the Chromium issue tracker to prevent such things in future, as many users would be hurt by this.

To be clear: I had to manually recreate all my styles. It seems they were lost in an unrecoverable way if I am not mistaken.

Same here

This brings back one question that I'd like to have answered here clearly:

Can WebExtension create file in its own folder without user interaction?

Pardon this silly hijack and my ignorance; I've searched for this simple information and my currently limited knowledge suggests it is not possible, but I think it would be beneficial to have such stance around here somewhere, so the questions like _"why doesn't Stylus do periodical automated backups"_ is answered beforehand.

Can WebExtension create file in its own folder without user interaction?

Webextensions can download files without user interaction by using the downloads API. However, the location must be inside the default download folder.

BTW, someone had suggested synchronizing styles through cloud services. See #82.

Can WebExtension create file in its own folder without user interaction?

No, this isn't possible. Why? Because reading/writing local files opens many attack vectors for malware (ref).

I found that there is a method to use the IndexedDB file storage library (ref); but after some digging, it appears that this method still uses the indexDB to store the blob. It's not storing an actual file outside of the database.

What else can be done?

Earlier in another discussion, Tophf mentioned working on a time machine, but he's taking a break from Stylus and he didn't share any specifics of his idea with any of us.

Currently, the user can export all the styles to the download folder by using the manage page "Export styles" button. After which, the file is safe from data loss by whatever is causing the issue reported here; but a user may never open the manager...

The only solution I can think of would be to periodically replace the popup contents with a reminder and an export button. This is necessary if a user rarely opens the manager or popup. Would that be annoying? yes, so we would need also to add an option to disable it.

And please let's keep the discussion about backups in issue #278.

Same issue here, after the update all my styIes in IndexedDB had a value of "null" however I was able to manually recover all of my lost styles by combing through the "000003.log" file located in AppData\Local\Google\Chrome Dev\User Data\Default\IndexedDB\chrome-extension_clngdbkpkpeebahjckkjfobafhncgmne_0.indexeddb.leveldb\ as it had not been wiped by the recent Canary update and contains readable CSS information.

Chrome Version 72.0.3595.2 (Official Build) dev (64-bit) also has this bug, all styles are deleted. I cleared all storage for Stylus tried the import option, doesn't work.

After deleting the database, you have to restart your browser (extensions).

Update to 72.0.3597.0 has deleted all styles again. Maybe this is intended as a side-effect of the fix.

https://bugs.chromium.org/p/chromium/issues/detail?id=899446#c14 :

If you recreated the styles in the broken Canary, it made the data incompatible with the fixed version, so I guess you'll have to recreate them again or restore a backup of the old pre-buggy database.

Okay, so after the last update, my styles are back. However the manage page is still empty. When i disable and re-enable any style it appears in the manage page temporarily, because when i refresh the page or toggle "New manage UI layout" it disappears.

capture

capture2

@sovmu Does exporting styles work? If so, you can try and reinstall stylus and import the styles to see if the problem persists.

@sovmu Does exporting styles work? If so, you can try and reinstall stylus and import the styles to see if the problem persists.

Thanks, it worked!

When I hit the update in chrome that zapped away all my styles it took about 20 seconds to fix. Open dev tools, Go to the Application tab index.db on the left over there and delete the stylus (stylish) db, restarted Chrome and then imported yesterdays backups because everyone knows that if you make changes to styles you create a new backup (export styles) I was back up and good in 20-30 seconds. It did affect New tab tools too but then again my backup habits saved me again. (I would suggest copying the DB out if your not sure of your backup)

To TL;DR the link above to crbug #899446, this is fixed in 72.0.3597.0, which isn't (yet) available to dev channel users but should soon be.

I have the same or very similar problem on Firefox 63, not in Chromium v70.0.3538.77 (running Linux, kubuntu 18.04). I am going to open a new issue because the _title of this thread is misleading, makes it seem a Chrome issue only_ and was not easy to find that this one was same issue and now I see it has been closed "fixed upstream", which doesn't help firefox users. For me it was never broken in my Chromium and it is broken in Firefox.

@ocumo It would be nice if you can open a new issue with detailed information :+1: This thread is related to a database bug in Chrome and they definitely are not the same problem.

@vsemozhetbyt issue should be re-opened, it regressed again in the last Chrome build: I'm using Chrome 72.0.3622.0 (Official Build) dev (64-bit), and Stylus fails to load my styles, with this error in the console:

Uncaught (in promise) TypeError: Cannot read property 'id' of null
    at db.exec.then.event (chrome-extension://clngdbkpkpeebahjckkjfobafhncgmne/background/style-manager.js:399)

Can confirm for 72.0.3622.0 (Official Build) dev (64-bit), but strangely not for 72.0.3624.0 (Official Build) canary (64-bit) (fixed there?).

Can confirm for 72.0.3622.0 (Official Build) dev (64-bit), but strangely not for 72.0.3624.0 (Official Build) canary (64-bit) (fixed there?).

@vsemozhetbyt good to know! count on me to ping you here with a status when the next Dev (not Canary) build lands.

@vsemozhetbyt @Mottie bad news: testing Chrome 72.0.3626.7 (Official Build) dev (64-bit) / Ubuntu that just landed in the repos, styles still fail to load, and the console still shows:

Uncaught (in promise) TypeError: Cannot read property 'id' of null
    at db.exec.then.event (chrome-extension://clngdbkpkpeebahjckkjfobafhncgmne/background/style-manager.js:399)

Yeah, I had to clear IndexedDB again and import my saved styles.

Has a bug been opened in the Chromium tracker for this issue? I can't seem to find one.

+1, it's broken a long time ago.

@karolyi Would you please be more specific? What issue are you encountering?

@Mottie No style is applied to the pages, and I can't browse for styles.

same here with latest chomium 75.0.3753.4 dev channel compiled by me

~
[47101:47101:0411/192006.364190:INFO:CONSOLE(400)] "Uncaught (in promise) TypeError: Cannot read property 'id' of null", source: chrome-extension://clngdbkpkpeebahjckkjfobafhncgmne/background/style-manager.js (400)
~

greetings

Outdated. If you have any similar issues in the future, open a new issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Tamschi picture Tamschi  Â·  3Comments

ExE-Boss picture ExE-Boss  Â·  5Comments

tophf picture tophf  Â·  5Comments

tophf picture tophf  Â·  6Comments

stonecrusher picture stonecrusher  Â·  3Comments