Which exception was that? "attery" is not defined?
So just to be clear, you ran require('Storage').compact() and there weren't errors, but then when you long-pressed BTN3 you started seeing errors, even though the app worked fine before the storage compact?
Yes. To be clear, I was on the morphing clock app just so our own app wouldn't be running during compaction (as the instructions above seem to only ask to run the app after compaction). The error I saw was indeed the above
"attery" is not defined. It didn't break the app per se, only the current running instance of the app. I did another reset and it worked fine. For context I had ~300 files (260-512 bytes each) in storage, in total probably < 200 kB.
How did you check the contents of the file? By loading it again with the IDE?
Or was it just that you saw \ff in the stack traces from errors?
By opening the file using the storage tool in the IDE. Just to be clear this is our own app's file, this and the
"attery" is not defined error (which happened while running morphing clock) were two separate issues. I knew it was \ff because the file viewer in the IDE was showing hex alongside ASCII.
By the way I did the above compaction steps again, and this time a different error (once again from the morphing clock app):
Uncaught ReferenceError: "fffa" is not defined
at line 1 col 3
W+CHARP;var d=new Date();g.reset();g.setFont("6x8");g.setFontAlign...
in function called from system
at line 1 col 1
fffaff ? ? ? ? ffafffff ? ? ? ? ? ? ? ? ffffa? ? ? ?...
It happened after I moved my hand, instead of after long pressing BTN3.
If you can actually reliably get the file corrupted by running compact then that's great - if you can send me the steps (privately if you need to keep your code private) such that I can reproduce it then it'll be much easier for me to fix.
The corruption is not actually reliable. It only happened the first time I tried running compaction. The next three times were fine. That said every time I did it the morphing clock app seems to throw errors, so that one is reliable.
As for the replication steps:
- Run our app, and start logging. Since I haven't yet sent you the code, the way this works is using a combination of StorageFile and normal fixed-length files. StorageFile (in base64) is used to allow for appending, and once that StorageFile reaches a given size limit (currently 349) the content is converted to binary and moved to a fixed-length "checkpoint" file.
- Leave it running until it starts throwing errors continually.
- Reset Bangle.js and go back to the morphing clock app.
- Perform the compaction steps above while running morphing clock
- I'm not sure what will fail here. 3 times out of 4, long-pressing BTN3 throws an error, and 1 out of 4, moving the device throws an error.