BindToClose causes Studio to freeze until it finishes

I don’t have any extra info for this bug. ( read the linked topics )
But a possible solution is to add a settings option that users can toggle if they want to wait until BindToClose finishes.

Code

local seconds = 30
local waited = 0
local interavels = 0.5

game:BindToClose(function()
	while task.wait(interavels) do -- you can replace all of this with task.wait(30)
		warn(waited)
		waited += interavels
		if waited >= seconds then break end
	end
end)

Files

BindToClose Bug.rbxl (57.1 KB)

More info

if you set the task.wait to 30 seconds it’ll throw this error

Similar BindToClose bugs:

BindToClose 100% Infinite Yield - #107 by nsgriff

Studio Hang On Ending Test In Window - Not running script because past shutdown deadline

"Not running script because past shutdown deadline (x8)" after 30 seconds, when stopping a debug


please read my reply for more info ( why I think this is a bug, and the expected behaviour)

1 Like

The other posts you linked all seem like different bugs. None of them were actually yielding for 30 seconds or more, but your code is. I think this is an intended behaviour of :BindToClose because it is literally waiting for 30 seconds like you wrote the code to do before allowing the playtest server to shutdown.

2 Likes

oh sorry, mb.
Ty for telling me.
Tbh I made this post with an assumption that someone else has already reported this bug (because I noticed it a year or 2 ago), and just searched the error message.

Yeah it’s intended behaviour in a “live” server, but in Studio it should [spoiler]imo[/spoiler] either run the BindToClose in the background, or ask the user if they want to wait.
… or at least let us know that this can happen in the docs, because I had a hard time tracking the problem.

Hanging the whole studio and freezing all inputs without a message indicating that it’s loading/closing the server made me think it was a bug, because that’s very similar to crashing [spoiler]( I’ll wait for a staff member to let me know if it’s not )[/spoiler]

+I used task.wait(30) as an easy way to simulate a heavy task, or a few yieldable apis/functions.