Data Often Not Populating in Application Until After Reloading Page (Salesforce)

Hello,

In our application, we very often run into users being greeted with pages that do not have any of the data populated. It is similar to how the page looks when the authorization token has expired. Initially this is what I thought the problem was (even though they were not being greeting with the authenticate resource popup) and instructed them to login with an auth button in our application. However, they have to do this extremely frequently which is problematic. Anyway, when they are greeted with the unpopulated page reloading the page will actually then work and the data will get populated. No need for them to relogin. So it is basically like the Salesforce resource queries sometimes just do not run on page load.

For reference this is what our page would look like when the data is not being populated:

These users experiencing these problems do have use access to our Salesforce resource and it will pull in the information after a reload and for a brief period after when users go to the page again but after some time they will once again be greeted with no data populated and need to refresh the page. This happens to me as well on occasion as the admin.

I had a user open the dev console in their browser to see if there were any errors and they did report back a log with some 400 errors. The 403 errors make sense I suppose as that user just does not have access to those queries in the 403 errors. But the 400 error queries they do have access to and will load for them on a refresh: (the component is orphaned stuff is not relevant, something I need to fix down the line haha)


I will sometimes come up against this data not populating as well, though when I open the console, I do not see any direct 400 errors but looking at the network tab I do see that no get requests were ever made. It will just be one post request whereas when the app is functioning there will be a number of requests:

It feels like the user is just timing out way too soon and then clicking reload is "reauthorizing" and allowing the queries to go through.

I am using the cloud version of Retool so it does not seem there is any way to really control when users would need to reauthorize in Salesforce but they are never being told they need to reauthorize. The data just won't load frequently until they refresh and then the queries will activate. Not sure if this is just a strange thing with Salesforce integration on the cloud version. Salesforce can definitely be strange.

Thanks for any help and sorry for the long post just at a bit of a loss on what is directly the issue here and how to resolve it so users don't have to be constantly refreshing.

Hey dmull, It might be that users are being re-authed in the background at first and that process hasn't been completed by the time the page loads. To troubleshoot this issue, it would be very helpful to see a screenshot of your resource setup page. If you don't feel comfortable sharing that publicly here (which would be completely understandable), then please write open a chat with us in Support and we can help you from there!

Hello Everett, thanks for the response. That does seem like it could potentially be the issue. Attached is our resource setup. Options are pretty barebones for SF so not sure what I could change to fix this.

Thanks for the help!

I see, thanks for sharing that anyways :grinning_face_with_smiling_eyes:

If this is potentially a race condition, then can you see if putting a delay on these queries that run on page load resolves the issue of having to reload?

Also, what is your Salesforce Timeout value set to?

This could be causing users to have to re-auth more frequently than desired.

Thanks for the page load delay tip! I should have looked for that in the query settings beforehand. I have implemented that now and am hoping that will have some positive effect if it was indeed a race condition issue. I'll be testing the next few days to see if it has fixed the problem.

As for the Salesforce timeout, we currently timeout sessions at 8 hours so probably would not be a factor in users having to reauth/refresh in Retool multiple times throughout the day. When they are using Retool and run into this problem of data not loading, they are still logged into Salesforce and can use that platform with no issue as their session has not technically expired.

Hello again,

It seems the issue is still going on where users will often come to a Retool page using a Salesforce resource where they will need to refresh the page before any data will populate. This is persisting even after I implemented a page load delay on all queries that run on load. Is it possible this is just some sort of bug in Retool with connecting/authorizing to Salesforce (Salesforce can definitely be weird) because we also have apps that use graphql resources that work without this issue at all? I can see an expired access/refresh token error on queries but this resolves after a page refresh and is happening way too often throughout the day.

Thanks!

Hey dmull, I'm sorry to hear that my suggestion wasn't helpful :slightly_frowning_face: After taking a second look at your issue with my teammate, we're not convinced that this issue is directly stemming from the auth on this Salesforce resource. It would be very helpful for us to see the full status 400 errors your users are getting here:

Are you able to share these full errors?

It would also be helpful to get a better idea of which queries specifically aren't running and how those queries are set up. I see you have this feature selected:

Are the queries that are failing to load all using this Sungage resource or are some of them using different REST API resources? Is there a clear delineation between the queries that are failing to load with status 400 errors and those that are failing with status 403 errors or does this appear to be random?

One other thing that is odd is that you're seeing different behavior than your users. This could indicate that the issue is somehow related to Retool permissions. Could you try promoting one of your users to the Admin group like yourself and see if they start seeing the same behavior as you?

Hey again, sorry for the late response on this.

Apologies, I am not entirely sure what is meant by full status 400 errors but clicking into the errors in the console we will see "Cannot GET /api/pages/uuids/00b07b60-811e-11eb-9fc6-9f69550df0df/query" for all the queries triggered to run on page load.

All of the queries that are failing to load are using this Sungage resource. In this application we are only using that one Salesforce resource.

There is a clear difference between those with a 403 and 400 error. The 403 errors make sense for the user that was getting them because I disabled those queries for their user group. The 400 errors make less sense and again once they refresh the page (no need to even full reauth) those queries will then run fine and they will see what they need to see populated.

For this last point about seeing different behavior, this was actually somewhat related to my browser. I would run into the exact same problem the other users were running into (i.e having to refresh very often to get the data to populate). The only difference was I would not see any 400 errors (or errors at all) in the dev console. This was on Firefox. However most of our users use chrome so I have been trying it there and now I will actually see the 400 errors for my user as well which is sort of strange. But either way, I do see the same logged errors as my users now and also another admin user has seen these errors in the dev console before when encountering this issue (also using a chrome broswer) when I was not seeing the console errors in Firefox.

Looking at the queries themselves that are erroring out in the Retool edit mode (which switching into edit mode when the error is happening will solve the error anyway since the request is made again and the data will then populate after that request) when I am already in that mode and encounter this problem, I just get the classic "expired access/refresh token".

Since this gets resolved when a user refreshes their tab it seemed like it was just some sort of miscommunication between Retool and Salesforce when it comes to refreshing authorization that Retool isn't grabbing from Salesforce until a decent amount of time after the page loads which is why then reloading the tab will work with bringing data in but I am not sure obviously haha. I did add a decent amount of page load delay on the queries that run on page load but that did not solve the issue and adding any more time would be kind of too slow for users anyway.

Thanks again for looking into this and let me know if any more info would be useful!