bluesky-social / feed-generator

ATProto Feed Generator Starter Kit
MIT License
919 stars 329 forks source link

Subscription cursor is not actually being saved #49

Open mackuba opened 1 year ago

mackuba commented 1 year ago

There is a problem in the FirehoseSubscriptionBase implementation of updateCursor(). It makes an update to the sub_state table to put the current cursor state there, but since no one has inserted any rows there previously, the update doesn't do anything.

The method should either first make a select and then either insert or update, or some kind of "insert / on conflict" (but there would need to be a unique index), or insert a null row there at launch. I don't know how you'd prefer to fix this, so I'm leaving this an an issue w/o a PR.

benharri commented 1 year ago

i fixed it in mine with this commit https://github.com/bluesky-social/feed-generator/commit/adabfbb7a339a24414b2f8a9e979593f930a6b93

mackuba commented 1 year ago

I had one more thought about this while adding this feature to my code now - I think it would be good to keep it optional and not on by default in development mode, only turn it on when deployed in production.

In development on a local machine, it will be normal to have the script running for some time and then not running when the developer is not working on it. So if they turn it on e.g. in the morning and kill the script and then restart it again in the evening, they would suddenly get a whole day's worth of events to process…