Sleitnick / Knit

Lightweight game framework for Roblox
https://sleitnick.github.io/Knit/
MIT License
568 stars 97 forks source link

GetService infinite yield #202

Closed CaptinLetus closed 4 months ago

CaptinLetus commented 2 years ago

If you call GetService/GetController on a service/controller that does not exist, I believe the current functionality is to yield until that service/controller exists

It would be nice if, after 5-10 seconds, we got a warning like Possible infinite yield while getting service "Name"

Without this message, the developer gets no indication that there might be an issue

Sleitnick commented 2 years ago

Looks like this is related to the Comm module:

The only yield would be GetService from the client. The first yield is waiting for the Services folder, which uses WaitForChild without an explicit timeout, which should give the expected infinite yield warning.

It then calls ClientComm.new, which has a WaitForChild that does have an explicit timeout (set to 60 seconds). If the WaitForChild times out (returns nil), then an error is thrown that the folder could not be found.

I see three possible solutions to this, and I favor the last one:

  1. Reduce the default timeout waiting for the comm folder
  2. Remove the timeout waiting for the comm folder (thus giving the desired warning)
  3. Add an attribute on the Services folder which communicates to the client what services will be available (just a comma-separated list of service names). Then throw an error immediately if the service is certainly not going to be available.
CaptinLetus commented 2 years ago

I agree, the third one seems like the best solution

CaptinLetus commented 2 years ago

That method might have issues if someone added a comma to their service name

Sleitnick commented 2 years ago

True, which I feel like is a "why would you do that" sort of thing, but probably worth encoding the name perhaps. Similar to URL encoding. Easy to do and would make sure the delimiter is captured properly.

ImFarley commented 7 months ago

Hi - I've been using Knit for about 3 years now and last night I had this occur for probably the 3rd or 4th time. I renamed a service that I was using in one of my controllers and could not for the life of me figure out why KnitStart was no longer firing on the client. There was much profanity followed by me shutting down the computer for the night.

Was just wondering if you ever landed somewhere on this issue? Of course it's largely user error and you'd think after doing it several times I'd like... stop... but I thought I'd whine about it anyways. Thanks.

Sleitnick commented 4 months ago

248