Storage Engine Returning Objects In Order Different From Requests

Hello!

We just updated our Nakama server framework from 3.17 to 3.21. We are also using the TypeScript runtime.

One thing that I noticed was that when reading objects from the storage engine(e.g. nk.storageRead(readRequests)) the results were returned in alphabetical order rather than the order of the requests array. We had some code that was relying on that ordering and it had been that way for a long while with no problems so that sorting change disrupted us for a little bit. Thankfully it was easy enough to fix.

I didn’t see anything in the release notes that mentioned this specific ordering change. Was this change intentional as a part of other storage engine work? Tangentially, are there any effective strategies for testing the server after updating the Nakama image that you can share? I am looking for what best practices I can implement such that I can avoid being caught off guard by these types of changes we updating the Nakama image.

Thank you for your time!
Chris

Hello @chris1, storageRead never guaranteed an ordering for the returned objects, this is why there’s no mentioning of any change in the release notes, the ordering you observed must’ve been coincidental, and it likely changed because of some adjustments to the underlying queries in the upgrade.

We do our best to cover any API changes in the release notes.

I’d recommend you have some integration tests against a live version of Nakama running your custom code, and you’d exercise it through some custom RPCs, which may or may not only be exposed in testing environment.

Hope this helps.

1 Like