tiddly-gittly/tiddlywiki-plugins

watch-fs stuck in unknown loop

xeor opened this issue · 7 comments

xeor commented

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

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..

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

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?

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

xeor commented

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

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.

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