The first image load isn't displayed

Feature(s) impacted

default GET route

Observed behavior

After the first loading of the user, the image will not be displayed, after I go one step back and again to the user, the image is displayed correctly.

first load:

second load:

image

Here is my code:
image

getUserDoc function is returning signedUrl,

Hello @Michael :wave:

Do you have any error in the browser’s console ? If yes, can you share a screenshot ?

Can you share a screenshot of Chrome Developer Tools > Network > [the request that load the verification data] > Headers, Payload and Preview tabs, for the first request without the urls and the second request with the urls.

Can you do console.logs in your route to check the values of record.docUrlFront and record.docUrlBack before and after the calls to getUserDoc ?

Thanks :pray:

Not loaded:
headers


preview

payload
image

loaded:
headers


preview

payload
image

console.logs - they are the same
not loaded:

loaded:

Looks like your route works fine.

Is it always broken on the first load and always working on all subsequent loads or does it happen to work on the first load or to be broken on subsequent loads ?

Do you experience this issue with every file format (jpeg, png…) ? With every record ?

Looks like you get a different URL on each request for the same file. Could you copy here some URLs that worked and some that failed ?

It doesn’t happen everytime. Sometimes it’s loaded even on the first attempt.

Here are wowrking urls:
working url v1
working url v2

and here are the ones that did not load
not working url v1
not working url v2

The URLs that didn’t work on your end work fine on my end.

Looks more like a random timing / race condition type of bug on our side. I continue to investigate.

Hello @Michael

I’m still stuck on this bug. I’ll do a quick fix today so we have more infos in the browser console when the image isn’t displayed.

While I’m doing that I just thought of another test you can do. I you change your docUrlFront and docUrlBack fields display widget from File viewer to Text then go to your record and refresh a good number of times, you can check if you always get the correct URL constructed by getUserDoc or if you sometimes get something else.

So I tried changing the layout of docUrlBack and I found that url doesn’t really change sometimes even if I can see signed url in the console.

Did not load case (I changed layout only on Doc url back):


urls returned from getUserDoc:

working case:


I’m not really sure why that happens. Maybe sometimes there is an error in your route override in the try block but the unchanged record get sent anyway because you call next in the catch block. You might be able to pinpoint that with more console logging.

You could also remove the route override and use two smart fields instead like that :

// forest/verification.js

fields: [
  {
    field: 'signedDocUrlFront',
    type: 'String',
    get: (record) => getUserDoc(record.docUrlFront),
  },
  {
    field: 'signedDocUrlBack',
    type: 'String',
    get: (record) => getUserDoc(record.docUrlBack),
  },
],

Let me know if any of those methods work for you :wink: