Record `position` property returning a stale value

Record position is not being updated unless I clear the environment’s cache, and this is now happening across multiple projects. This is breaking a lot of my production sites right now, as I have to manually go in and clear the cache for every build that affects record position.

This was first noticed by a client last week. Prior to this, they were able to reorder records without issue. There were no code updates to the front end in between record ordering working and not working.

I have used Dato for quite a few projects now, with Gatsby on the front end, and this is the first time I’ve encountered this issue. I am using gatsby-source-datocms, and this problem is happening in both local dev environment and in production on Netlify.

Hello @clay

How are you clearing the cache manually?
Could you also send us an example of a stale request response you received at so we can take a closer look at it and try to identify the problem?

In production (Netlify), I have to go into the dashboard and select “Trigger Deploy” → “Clear cache and deploy site”.

In development, I have to run gatsby clean before the usual gatsby develop command.

I will send some examples.

Hello @clay, can you please confirm which version of the Gatsby source plugin and which version of Gatsby are you using?

Also, can you please confirm that you are changing the position only? Nothing else in the record?


The bug was first noticed on a site running gatsby 3.11.1 and gatsby-source-datocms 2.6.16. I upgraded to the latest versions, gatsby 4.24.4 and gatsby-source-datocms 4.0.4, and the bug still occurred.

The other site that I tested and confirmed the bug on was running gatsby 4.16.0 and gatsby-source-datocms 4.0.4.

In these cases, I have only changed the position.

An interesting thing that happens in development is that the change is detected when the positions are changed, and gatsby appears to update, but the data stays as it was prior to the change:

success detected change in DatoCMS content, loading new data - 0.305s
success building schema - 0.852s........

If I then change some other data in the record, then the whole record updates as expected, including the new position. BUT the position values for the other records do not update, so I end up with stale position values for all the other records of that type.

Edit: I have tested a third site and the bug occurs on sortable records there as well, running latest package versions.

Hello @clay, I’m very sorry for the delay in getting back to you, it’s my bad.

I’m going to try to reproduce this and get back to you as soon as possible, probably tomorrow!

Hey @mat_jack1, no worries! Thanks for looking into it.

hey @clay we have just released a new version of our source plugin that also fixes your bug: can you please try upgrading and let me know? Thank you!

We also released v4.0.5 with the fix, if you’re under v4!

Thank you for the update, @s.verna @mat_jack1.

Testing with v4.0.5, however, I am only seeing a partial fix. If I change the order of a record, now the ‘position’ value is properly updated for every record except for the record that I moved.

For example, if I build the site and run the query on following record:

I initially get the query results:

Reordering ‘Record A’ to the bottom position:

Gives these query results:

Notice that records B, C, and D have the proper position, while the moved Record A retains its original position value.

In my tests I cannot reproduce the issue you’re referring to, sorry :confused:

To help me, could you please specify:

  • gatsby exact version in yarn.lock
  • your DatoCMS project ID

Also, can you confirm that in your yarn.lock file you have version 4.0.5 of gatsby-source-datocms?

Hi @s.verna, I am using npm so it’s a package-lock file, but the exact versions are:

  • “gatsby”: “^4.24.7”,
  • “gatsby-source-datocms”: “^4.0.5”,

The project ID that the lasts tests were run on is #45951.

To reproduce, you first need to run gatsby develop, and then after the project is running locally, change the order of a record. You should see the order update for all records except for the one that was moved. Running gatsby clean and Restarting dev environment will make everything appear correctly again (* No longer need to run clean, simply rerunning develop works).

EDIT: It looks like the bug is now fixed in production as well, and is only persisting in development with Gatsby’s hot reloading.

Alright! The issue should be fixed now! Thanks for helping/following us so thoroughly :pray:

1 Like

Fantastic, thank you @s.verna and @mat_jack1 !