Anvil tables update not happening actually

@stefano.menci
I confirm you followed steps properly and your results are correct.

Only thing is that it should work multiple times by refreshing the app.

One thing i would request is to do the same in production environment. By clicking publish and visiting the displayed site

Otherwise, I am surely going to make a video of bug and would try to design an app from scratch

Console is okay, but tables ui should also contains the exact same code displayed in console.

Cuz for me too, console is showing correct results, but tables ui is not updated.

Can you please provide the steps, including actions to execute and things to check, similar to what I did in my previous post?

I would rather spend time reproducing and investigating the problem than trying to reverse engineer what I’m supposed to do.

A list of steps is better than a video, because sometimes the same action triggered by a mouse click doesn’t behave the same way as if it’s triggered by a key stroke or another event.

… but a video is better than a list of steps, because the video may show some clue that is not included in the list of steps :slight_smile:

2 Likes

Here’s a video of the bug: Anvil tables not updating sometimes - YouTube

It’s happening sometimes only, so its hard to reproduce the bug. It took hard time for me too to record the video with the bug. Anyway, something is wrong with tables.

Here’s a minimal clone showing the issue (getting rid of all the app specific bits helps to narrow down what’s needed to reproduce the issue): Anvil | Login

In the clone, to reproduce the problem:

  1. Publish the app
  2. Run the app through the published link
  3. Update the value of “foo2” by entering a value in the edit field and click the update button
  4. Verify the update worked by clicking to fetch the value
  5. Go back to the IDE UI to see the data table hasn’t changed

There does seem to be something odd going on. It might just be a delay in the IDE updating, even with the refresh button being used.

In the video I see a lot going on, but I don’t know:

  • what should happen
  • what is happening instead
  • what function doesn’t produce the expected result

One thing that I see is that you have the ide open on the table. I don’t know why you have it open, you don’t explain it, but I know that keeping that page open sometimes rewrites the old data in the row. And I don’t know if that’s the problem either. For example if you open a table and click on a row with the value “x” in a column, then run the app that writes “y”, sometimes that page will write “x” back even if you didn’t explicitly ask for it.

A better way to check the content of a row is to use a server console to execute a search and print the result. It’s faster than clicking and scrolling, you don’t risk to accidentally edit the data and allows you to print a specific item of a large simple object.

While i am glad that you were able to reproduce the bug (the bug wasn’t good but)

I want to make my point that it’s not just an ui update problem. The clone i put here was part of a somewhat bigger hobby project where each coupon was designed to be used only once.

In short, i made a function to check to allow only if coupon code was null (still not used). Guess what? It allows me to use repeatedly, the reason being same, tables not updating sometimes.

It may be a flush problem cuz i printed same dictionary at 3 diff points in same server run and all 3 are same and expected. But that update can’t be seen in ui but internally too it isn’t actually updated.
Seems like a single server run is caching tables and returning correct values but doesn’t get updated till next server call.

1 Like

You’re making an assumption that may or may not be true. In my runs of my simpler app, I saw:

  1. The IDE UI not being updated
  2. The production app returning the right results even after a refresh of the app (so there was no caching involved)
  3. The production app returning the wrong results after a refresh
  4. The IDE UI updating after a few minutes had passed
  5. The row disappearing from the IDE UI. This persisted even through using the refresh button, but matches what you see when the refresh happens slowly (existing UI rows disappear, new UI rows appear).

All of those cannot be explained by either the UI being slow to refresh or the data tables not updating. There’s something more complex going on that needs looked at by the Anvil folks.

1 Like

The only way to rule out the ui is to not involve the ui in the tests. From my point of view you are testing the ide, not your app. And I can tell you that I know that there are problems with the table editor in the ide, one of them (not the only one) is described here.

Were you able to reproduce the problem by checking the content of the table with the server console, without keeping the table open in the ide?

Or by adding a button on the form that shows the content of the last updated row in an alert?

Or by creating a second app that just checks the correct behavior of the first app?

I wasn’t, simply because all I know at this point is that you claim that there is a bug, but still don’t describe how to reproduce it or even how to check the correct behavior. You say something isn’t updated, but I still don’t understand what.

I’m not claiming there is no bug. All I’m saying is that there are tens of thousands of Anvil apps out there and it’s very unlikely (albeit not impossible) that you are the only one affected by this bug. And that there are thousands of users out there and we all are affected by the quirks and bugs of the ide. So I tend to (very strongly) believe that the problem lays either on the way you use the ide to test it, or on a bug in the code.

2 Likes

This inspired me to suggest a new feature, to reduce the occurrence of these issues.

1 Like

An addition to information related to bug is that it is not just limited to simple python objects like dict but affecting text column also.

What i did?
I tried to stored dict as string. In my code its converted using eval to dict, values changed and then again converted to string and pushed for update.
To my surprise, the bug remains as it is.

I can’t reproduce any problems with this clone link. The Anvil IDE is not constantly refreshing so you’ll need to click the “refresh” button next to “Permissions” to refresh the table. I’ve run the app several times and after refreshing the table, everything is updated as expected.

(Thank you for providing a minimal clone link)

In this video, you have clicked the cell in the Data Table and are editing it. Even though you add a new value through the live app, you are actually editing the table in the UI, so whatever might be happening in your app, that value is being overwritten as you edit the table in the UI.

There might be a bug here, but please provide a minimal clone link with followable reproduction steps.

2 Likes

As a reminder to everyone, it is much, much easier for the community to help out if you provide code snippets and/or a clone link to a minimal app with clear, straightforward reproduction steps. Most people (@stefano.menci, @p.colbert and @jshaffstall are exceptional people and we are lucky to have them on this forum) will not take the time to decipher large apps, and you won’t get the help you’re looking for.

5 Likes

I can confirm that’s what was happening with my minimal clone link. The end of the JSON could not be seen in the IDE, so to check it I would start editing the field to see if it had changed. If I did that before refreshing the IDE, editing the field would set it back to the original value.

When I increased the column width enough so I could see the entire JSON string without editing it, a simple refresh of the table in the IDE always showed the new value.

4 Likes

Hmm, seems reasonable. So, there is error only if we see it.

This seems closely related to that Schrodinger’s cat :joy:

I will figure out a way to test if there is error when no one seeing, then would mark it as solved.

Finally, i the issue is solved.
The bug was only there if we want to see it happening live in ui cuz edit mode override the updated value.
Thanks @brooke for your so precise observation we were unable to figure it out ourselves.

Also big thanks to @jshaffstall, @stefano.menci, @p.colbert to acknowledge and keep the issue alive

Additionally, i agree with @p.colbert idea to create a read only mode for tables ui. I agree with him that it will reduce occurance of such bug(confusion).

I’m seeing this in my app. The table only gets updated on the second or third server call. I’ll be posting my example app shortly.

If you read carefully, when “this” happens in your app, means that you are clicking on the table on the ide causing the ide to rewrite the old value to the table.

Whether this is the case or not, please don’t revive this old thread which already has a solution. You can create a new one, and add a link to this for reference if you like.

1 Like

Sorry, I figured out the issue. My bad.