How to force sync from server to browser using js?

My tiddlywiki setup is node.js under windows.

I have modified tiddler through external program and PUT into server. I understand I can reduce $:/config/SyncPollingInterval to reduce internal pull from server to browser.

But I want to force to sync from server to browser in js. I tested $tw.syncer.syncFromServer, which seems not working as expected.

Any ideas how to force sync from server to browser using js?

1 Like

At one point, I was told it can’t be done, so I just restart the server and refresh the browser when I need to. It’s usually quite quick for me.

I wish I had better news.

– Scott

1 Like

Thanks.

Set $:/config/SyncPollingInterval to a short period can quickly sync from server.

But I want to find a way to trigger sync with JS for my vs code extension for better editing experience

Right. That’s what I don’t think can be done. To do it would require triggering the startup mechanism, and that could well interfere with your running system.

As I understand it, this is not possible. The node TW design is about polling - initiated by the client (browser) to the server. There is no mechanism for the server to push changes to the client.

I believe the bob.exe version did utilise websockets (maybe?) for a constant connection and thus the server to push changes instantly, but afaik, bob is no longer maintained.

I’ve memory of this type of thing being discussed in context of MWS, but I dont know if it’s been implemented

Thanks. In my case, browser pulls changes from server.

I guess the system feature Get latest changes from the server suppose to pull changes from server.

image

In the debug mode, Get latest changes from the server calls function $tw.syncer.syncFromServer. But this feature is not working for me (not sure about the reason).

And the browser also sync from server with interval $:/config/SyncPollingInterval which works for me. Not sure how to trigger this sync with js.

It is very strange, $tw.syncer.syncFromServer is working today with only one change to start test tw.

Original

nodemon -e tid,js,css  --ignore $*.tid --watch dev/tiddlers  C:/Users/<user>/AppData/Roaming/npm/node_modules/tiddlywiki/tiddlywiki.js dev --listen port=8080 csrf-disable=yes 

The new one remove tid

nodemon -e js,css  --ignore $*.tid --watch dev/tiddlers  C:/Users/<user>/AppData/Roaming/npm/node_modules/tiddlywiki/tiddlywiki.js dev --listen port=8080 csrf-disable=yes