Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WaitFor module unusually long promise resolve time #181

Open
MohhayScripts opened this issue Dec 19, 2023 · 1 comment
Open

WaitFor module unusually long promise resolve time #181

MohhayScripts opened this issue Dec 19, 2023 · 1 comment

Comments

@MohhayScripts
Copy link

MohhayScripts commented Dec 19, 2023

When coding with Roblox's own API, and using instance:WaitForChild(childName), you get a warning after 7 seconds that tells you that the yield is unusually long.

With the WaitFor module, that isn't a feature but instead, the default timeout is 60 seconds, and the timeout forces the promise's "yield" to reject and error.

This behavior is fine, and I am making the assumption that 60 seconds force timeout time was set with slow runtimes running WaitFor code in mind, however, as I was testing earlier today some code for my game that uses WaitFor, I realized that the WaitFor wasn't resolving in an expected time frame and I stopped the test almost immediately after and started to print debug the code.

This is not very ideal as it takes more time than it has to take, and if I were to wait 60 seconds at least before closing my game, I would have figured out the exact problem!

With Roblox's own API in mind, I think introducing an "unusual length warning" would do well for the WaitFor module, and being able to set this value somehow (not required but would be nice) would also be good. I think that 7 seconds unusual yielding time would work perfectly, as it has for Roblox throughout all these years.

I do not want to create a PR alongside this since WaitFor uses promise functionality which I have no experience in using, so instead I am making this issue with a code snippet of how unusual yield time warnings could be introduced.

I am hoping that someone can create a PR, or that Sleitnick can just update the module himself if he thinks this functionality can be introduced.

Here's the code snippet of how you can implement the functionality described above when creating a Promise.

local unusualYieldWarn = task.delay(7, function()
  warn("Unusual yielding time for Promise, etc")
end)

local promise = Promise.new(function(resolve)
  -- Do whatever you want in your promise here
  if promiseResolvedSomehow then
    task.cancel(unusualYieldWarn)
    resolve()
  end
end) 
@MohhayScripts
Copy link
Author

MohhayScripts commented Dec 19, 2023

Below is an example of the warning that Roblox outputs after 7 seconds of yielding using a :WaitForChild().

image

It would probably be better to instead warn something along the lines of "Unusually long yield time" or so on for WaitFor's functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant