HTTP API functions that cache do not yield if they have a cached value

Issue Description
For a more descriptive title: This requests that functions that dont always yield due to a cache should be changed to CanYield.

This bug involves the deployed API dump with some of the functions. I put it here because I dont really know where to put it.

This documentation issue affects multiple APIs, including but not limited to

  • Player:GetRank/RoleInGroup()

  • (attempted to find more but see below)

(From further testing it appears MarketplaceService actually yields every time now, this is the only members, that I can find, that should be changed to CanYield)

As stated before, I dont really know where to put this since it’s an issue with the API dump.

You can test yield functions using this piece of code, if beep is printed multiple times in a row, then the function only yielded a few times.

local h = true

  while h do

for i = 1, 10 do
  game.MarketplaceService:PlayerOwnsAsset(game.Players.LocalPlayer, 1818)

h = false

Issue Area: DevHub Content
Page URL: API Dump

It sounds like it would be easier to have a tag that indicates if a function caches its result, thereby not yielding in the case of a cache hit.

The yield tag already carries an implication that something can sometimes not yield. Maybe updating our description of if it may be more helpful than changing the tag name or its inherent meaning. For reference, this is what is said now:

This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts.

For example, WaitForChild doesn’t yield at all if the child is already there. It yields, is tagged accordingly, but it’s widely understood that it won’t because it doesn’t need to. Similarly, caching functions like GetRankInGroup should carry the same expectation and be marked clearly. Sound better?

Probably a better way of doing this since it gives the developer more of a warning with it. :+1:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.