Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Changes to shopping list items immediately overwritten #3842

Closed
6 tasks done
ollywelch opened this issue Jul 3, 2024 · 10 comments · Fixed by #3847 or #3850
Closed
6 tasks done

[BUG] - Changes to shopping list items immediately overwritten #3842

ollywelch opened this issue Jul 3, 2024 · 10 comments · Fixed by #3847 or #3850
Labels
bug: confirmed bug Something isn't working

Comments

@ollywelch
Copy link
Contributor

First Check

  • This is not a feature request.
  • I added a very descriptive title to this issue (title field is above this).
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Mealie documentation, with the integrated search.
  • I already read the docs and didn't find an answer.
  • This issue can be replicated on the demo site (https://demo.mealie.io/).

What is the issue you are experiencing?

When editing a shopping list, any changes to the items get immediately overwritten. Having checked the server logs no requests are being made other than a periodic GET of the shopping list by ID, i.e. no POST or PUT to update the items. Weirdly I was able to add the first item, but nothing worked after that. Not sure if this is always the case.

screen-20240703-221047.mp4

Steps to Reproduce

Create a shopping list, and try and add or update some items.

Please provide relevant logs

See screen recording :)

Mealie Version

v1.10.1

Deployment

Docker (Linux)

Additional Deployment Details

Docker compose behind nginx proxy manager for reverse proxy

@ollywelch ollywelch added bug Something isn't working triage labels Jul 3, 2024
@ollywelch ollywelch changed the title Changes to shopping list items immediately overwritten [BUG] - Changes to shopping list items immediately overwritten Jul 3, 2024
@michael-genson
Copy link
Collaborator

Can you check your browser logs and see if anything is throwing an error there? (F12 on Chrome)

It's probably related to this: #3823

That PR was in the 1.10 release, but it broke shopping lists completely so it was reverted in 1.10.1. #3837 should fix any issues related to this, but I haven't gotten browser logs from any user experiencing this issue, so I don't actually know what's causing it.

Alternatively, if you're able, you can try pulling #3837 locally and seeing if your issue is resolved.

@ollywelch
Copy link
Contributor Author

I think I've located the issue at these lines in use-shopping-list-item-actions.ts:

const cutoffDate = new Date(queue.lastUpdate + queueTimeout).toISOString();
if (data.updateAt && data.updateAt > cutoffDate) {
    // If the queue is too far behind the shopping list to reliably do updates, we clear the queue
    clearQueueItems("all");
  } else {
    // We send each bulk request one at a time, since the backend may merge items
    await processQueueItems((items) => api.shopping.items.deleteMany(items), "delete");
    await processQueueItems((items) => api.shopping.items.updateMany(items), "update");
    await processQueueItems((items) => api.shopping.items.createMany(items), "create");
  }

My server locale is UTC+1, so updateAt is getting returned in that timezone, but the cutoffDate will always be an hour behind because we're formatting it as an ISO string. I tested my theory and I could make one update after 55 minutes of my last update (accounting for queueTimeout). After that, it was back to the same issue again.

I feel like the solution here is for the API to return timezone-aware responses, or to return everything in UTC. Probably the latter would be more straightforward to implement?

@ollywelch
Copy link
Contributor Author

Just to confirm, changing the TZ env variable of the mealie container to Etc/UTC solved the issue

@michael-genson
Copy link
Collaborator

Ah hah! Good catch, that must be it. I thought the API always returned UTC (actually I'm pretty sure other parts of the app assume it does) so I'll need to look into that

@Thoroslives
Copy link

Its odd as this seems to be fixed as above but i am having this exact issue and im on v1.11.0

As per the above i see no POST or PUT in my db only GET

when i look at the console in my browser it just says Out of sync with server; clearing queue regardless of browser used cache cleared or not

I have tried to set my container to Etc/UTC (didnt work) but that wouldnt make sense as my postgres db is in my local timezone. I have ensured both containers are running the same TZ still not working.

@michael-genson
Copy link
Collaborator

Try deleting that shopping list and using a different one, and/or clearing all of your browser's app data for Mealie.

@Thoroslives
Copy link

Try deleting that shopping list and using a different one, and/or clearing all of your browser's app data for Mealie.

Ive done that on multiple devices and browsers. Exact same behaviour

@michael-genson
Copy link
Collaborator

If you're using the PWA you may need to force it to update. Exactly how depends on what you installed it through

@Thoroslives
Copy link

If you're using the PWA you may need to force it to update. Exactly how depends on what you installed it through

This behaviour is on desktop and mobile browser and PWA

@Thoroslives
Copy link

Ive ended up switching the the sqlite db until i can work this out as it works as it should when using sqlite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: confirmed bug Something isn't working
Projects
None yet
3 participants