tiddly-gittly / tiddlywiki-plugins

Plugins developed for a better TiddlyGit.
https://tiddly-gittly.github.io/tiddlywiki-plugins/
MIT License
26 stars 6 forks source link

watch-fs stuck in unknown loop #8

Closed xeor closed 2 years ago

xeor commented 3 years ago

I'm using the kookma favorites plugin (https://github.com/kookma/TW-Favorites), and noticed that when I toggled favorite status of a tiddler, watch-fs got stuck in a loop.

The files /tiddlywiki/data/tiddlers/$__favorites_favlist.tid and /tiddlywiki/data/tiddlers/$__plugins_kookma_favorites_recent.tid is not being changed between each iterations.

I'm not sure if this is a problem with the favorites plugin, or if there are a general bug in watch-fs. I'll update the issue if I figure out some more

Here is an example of 2 iterations of the loop.

 syncer-server-filesystem: Dispatching 'save' task: $:/favorites/favlist
 syncer-server-filesystem: Dispatching 'save' task: $:/plugins/kookma/favorites/recent
$__favorites_favlist.tid update
tiddlersDescriptor {
  "filepath": "/tiddlywiki/data/tiddlers/$__favorites_favlist.tid",
  "type": "application/x-tiddler",
  "tiddlers": [
    {
      "title": "$:/favorites/favlist",
      "created": "NaNNaNNaNNaNNaNNaNNaN",
      "list": "aaa [[something]]",
      "modified": "20200915193938719",
      "type": "text/vnd.tiddlywiki"
    }
  ],
  "hasMetaFile": false
}
updating existed tiddler $:/favorites/favlist
Saving updated $:/favorites/favlist
canSync is now false
$__plugins_kookma_favorites_recent.tid update
tiddlersDescriptor {
  "filepath": "/tiddlywiki/data/tiddlers/$__plugins_kookma_favorites_recent.tid",
  "type": "application/x-tiddler",
  "tiddlers": [
    {
      "title": "$:/plugins/kookma/favorites/recent",
      "caption": "Recently added",
      "created": "NaNNaNNaNNaNNaNNaNNaN",
      "creator": "a revised version of Andrew Harrison favorite plugin",
      "list": "aaa $:/plugins/kookma/favorites/styles/image.css",
      "modified": "20200915193938750",
      "modifier": "a revised version of Andrew Harrison favorite plugin",
      "tags": "$:/tags/Favorites/Folder",
      "type": "text/vnd.tiddlywiki"
    }
  ],
  "hasMetaFile": false
}
updating existed tiddler $:/plugins/kookma/favorites/recent
Saving updated $:/plugins/kookma/favorites/recent
canSync is now false

//// Next iteration starts here...

 syncer-server-filesystem: Dispatching 'save' task: $:/favorites/favlist
 syncer-server-filesystem: Dispatching 'save' task: $:/plugins/kookma/favorites/recent
$__favorites_favlist.tid update
tiddlersDescriptor {
  "filepath": "/tiddlywiki/data/tiddlers/$__favorites_favlist.tid",
  "type": "application/x-tiddler",
  "tiddlers": [
    {
      "title": "$:/favorites/favlist",
      "created": "NaNNaNNaNNaNNaNNaNNaN",
      "list": "aaa [[something]]",
      "modified": "20200915193938719",
      "type": "text/vnd.tiddlywiki"
    }
  ],
  "hasMetaFile": false
}
updating existed tiddler $:/favorites/favlist
Saving updated $:/favorites/favlist
canSync is now false
$__plugins_kookma_favorites_recent.tid update
tiddlersDescriptor {
  "filepath": "/tiddlywiki/data/tiddlers/$__plugins_kookma_favorites_recent.tid",
  "type": "application/x-tiddler",
  "tiddlers": [
    {
      "title": "$:/plugins/kookma/favorites/recent",
      "caption": "Recently added",
      "created": "NaNNaNNaNNaNNaNNaNNaN",
      "creator": "a revised version of Andrew Harrison favorite plugin",
      "list": "aaa $:/plugins/kookma/favorites/styles/image.css",
      "modified": "20200915193938750",
      "modifier": "a revised version of Andrew Harrison favorite plugin",
      "tags": "$:/tags/Favorites/Folder",
      "type": "text/vnd.tiddlywiki"
    }
  ],
  "hasMetaFile": false
}
updating existed tiddler $:/plugins/kookma/favorites/recent
Saving updated $:/plugins/kookma/favorites/recent
canSync is now false
xeor commented 3 years ago

A simple

<$button>
<$action-setfield $tiddler="$:/favorites/favlist" list="aaa"/>
trigger loop
</$button>

will trigger the loop (and wipe out favorite list, beware!).

However, changing to any other path, example $:/favorites/favlist2 doesnt trigger the loop. So I guess it might be the favorite plugins mistake. This loop also happens when changing any of the settings of this favorite plugins..

linonetwo commented 3 years ago

Normally changes from the browser will be ignored, so their change to the disk won't trigger another change in the browser, causing a loop.

Seems in this case the change from browser is not properly ignored?

I have the favorite plugin installed, but I haven't use it at least once...So I didn't know this before.

xeor commented 3 years ago

I did see this issue once a couple of days with another plugin as well.. I don't remember which one, and I can't reproduce it. But yea, there might be some edge cases that isn't probably ignored then.

So you where able to reproduce?

linonetwo commented 3 years ago

This seem to be fixed now! Just by fixing #7

xeor commented 3 years ago

It still happens when I'm testing the new version. I'll investigate some more. Are you on 5.1.22?

linonetwo commented 3 years ago

No, I'm using https://www.npmjs.com/package/@tiddlygit/tiddlywiki 5.1.23-prerelease.20201003-fix-file-info

I need some new feature from the new tw.

linonetwo commented 2 years ago

Well... Not using watch-fs now, I mostly manually reload the nodejs wiki, it don't consume too much time...