Infinite yields due to BindableFunction.OnInvoke not being registered should be easier to debug

As a Roblox developer, it is currently too difficult to debug code which uses BindableFunctions due to the lack of diagnostics.

Take the following example:

Invoker script:

print("Invoking...")

local value = script.Parent.Function:Invoke()
print(value)

Implementer script:

-- <Some initialization code up here>

function script.Parent.Function.OnInvoke()
	return 5
end

Structure:

image

If some kind of issue prevents Implementer from assigning the .OnInvoke callback, Invoker will never resume and there is no indication from the Engine that it is currently waiting for the callback to be registered.

The “issue” could be, for instance, an infinite yield, an accidental early-return, or simply assigning the callback to the wrong BindableFunction. Debugging issues like that become far more tedious when the root cause is obscured. Calling a function which has not been defined generally results in an error, and is what I would think many developers (including me) will assume is what happens if they have not been keeping fully up-to-date with the Documentation.

Warnings like Infinite yield possible with Instance:WaitForChild attempt to mitigate similar development headaches, and I believe one can be implemented for BindableFunctions as well.

If Roblox is able to address this issue, it would improve my development experience because I would have to spend less time debugging code that uses BindableFunctions.

1 Like

I am not a professional but I guess the problem here is execution order of the scripts in ServerScriptService.

It should be only one global “init” script the rest should be modules that the init requires (and here you can control execution order).