BindToClose breaks when run from a script destroyed while the game is shutting down

So. This bug courses when you actually delete the callback for BindToClose. I’ve got a system where I use module scripts and somewhere in that i’ve used BindToClose on a function that was previously destroyed? After about 5 seconds ish or more being in a broken studio. It spams the console with an error. You’ll see in screen shots.

The bug happens when you try and leave “Play” mode. It will freeze. Show you an error where if you try and press “Show details” it’ll show you the console with only the previous errors (From your scripts etc. Not an actual error that I could use to fix it in game.) Aside from this. All the buttons now break. Your camera is broken. You physically have to leave studio and join back. This happens on Team create and on a Single Studio.

The bug must happen in an unknown script or a studio related script. I don’t know where it is or how to find it. It just throws me an error. And breaks my studio.

It started yesterday (Thu Jun 24th 2020) . Though I patched it, I’ve experienced it again so I came to the developer community.

Screenshots/Videos

SS:


Error:
image
GIF:
https://gyazo.com/0e685fa445520c4cd754bb2b6a35b737

Reproduction

For this. We’re just going to use two scripts. A module script, and a server script. I’ll show you the code in the following scripts.

Server:

game:BindToClose(function()
	script:Destroy()
end)

require(script.Module)()

Module:

local module = {}

return function()
	game:BindToClose(function()
		print("Game - Closed")
	end)
end

image

I’m not quite sure if you need my system specs or not. But either way i’ll list it here.

OS - Windows 10 Home
BUILD - 10.0.18362 Build 18362
CPU - Intel Core I7-8750H
GPU - NVidia GeForce GTX 1050 Ti

Destroying your script would obviously stop it from performing? I don’t know why you would ever need to destroy the script on a game shutdown.

2 Likes

I have a system of modules. Somehow the callback in my datastore module gets deleted/stopped. There could be something i’m missing. But the fact that my callback in my datastore module gets deleted. It breaks the game.

Thanks for the report! We’ve filed this internally and we’ll follow up here when we have an update for you.

2 Likes

Sorry for the bump, but I’ve just found the issue as well. This time, if a module calls it and encounters an error before it can completely return the module, BindToClose is still registered, but acts as though the code has been removed.

BindToCloseBug.rbxl (22.4 KB)

  • Example 1
    A. We require a module, that module calls BindToClose, then errors before returning. We experience our bug.
    B. We require a module, that module creates it’s own “sub module” enviornment (or attempts to do . Successfully closes.
    C. We require a module, that module calls the above but within a pcall. Successfully closes.
  • Example 2
    We require a module inside a pcall, the module will error like Example 1A before returning. We experience our bug.
  • Example 3
    After succesfully requiring the module (all examples commented), and then call Module.ExampleA we will error, but be able to succesfully close.

To my understanding, it appears as if there is an error in the environment containing BindToClose, then it will fire without “properly” being connected. Is there any way to check for BindToClose when erroring and disconnect them with an error in the output? If I wasn’t using an external editor, this would have taken me forever to figure out.

I am in the process of checking over bug reports and following up on some bugs that haven’t received any activity in a while.
Is this issue still occurring or can you confirm that this bug has been resolved?

This bug has been fixed, I’ve tested with the code I provided when I posted the bug; It shuts down accordingly. However doesn’t print the arguments I initially passed to it.

This issue should now be resolved! If this issue is still occurring, please create a new topic for us to look into.

2 Likes

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