BindToClose 100% Infinite Yield

As of two hours ago I have been getting:
image

every time I press stop from play solo in studio if there is a DataStore:SetAsync called binded to game:BindToClose()

This is reproducible and here is how:

  1. Make baseplate
  2. make server script, insert following code:
local dss = game:GetService("DataStoreService")

local ds = dss:GetDataStore("ds")

game:BindToClose(function()
	ds:SetAsync("akey", {})
end)
  1. Publish place and enable studio access to API services.
  2. Play solo, Stop.
  3. image

This is slowing down my work immensely right now as I am working with things save-load reliantā€¦

It is interesting to note that the data DOES save, SetAsync just seems to yield infinitelyā€¦

This started after the latest studio update tonight.

I donā€™t know if this is happening in live places, or only studio. I would consider this ROBLOXCRITICAL if it is happening in live games (as i fear it is)

BindToCloseSetAsync Repo.rbxl (12.5 KB)

NOTICE:
This happens with any yield, change the SetAsync to wait() and the results are the same.

50 Likes

Iā€™m going to publish this test on a live server. If it doesnā€™t save my data, Iā€™d regard this as ROBLOXCRITICAL.

12 Likes

It is saving my data, but I am only one person. If i were attempting to save a whole serverā€™s playersā€™ data, it would only save the first one as it yields on the first SetAsync.

4 Likes

I canā€™t even open your rbxl file, every time I do Studio crashes (separate issue).

5 Likes

Opens fine for me. Itā€™s a baseplate with 1 server script with the code supplied in step 2

4 Likes

Just tested, this is only in Studio thankfully.

3 Likes

How did you confirm?

3 Likes

I made a test place that saved 3 keys of data and read them back to me next visit in a BindToClose. In Studio, it saved the first and infinite yielded. On the site, it read all the data back to me next time I joined.

5 Likes

Probably related to this issue I was having while testing Accurate Play Solo a couple of weeks ago :arrow_right: Calling YieldFunctions from BindToClose functions hangs Studio after clicking Stop button

5 Likes

Still an issue that is halting proper development.

6 Likes

This has been happening to me too and it is slowing me down SO MUCH. Some people in my testing server also lost all of their data (even though i kick them from the game if theres an error loading their data and dispose their data object) last night about 3:30 am during the outage.

5 Likes

Can confirm Iā€™m having this issue too

3 Likes

This needs to get fixed, absolutely destroying dev time

8 Likes

If it is not critical for you to have the data saved, while this bug is not fixed, and you want to bypass the yeilds in your BindToClose function, at the beginning of your script, set a variable local IsStudio = game:GetService(ā€œRunServiceā€):IsStudio()
Then in your BindToClose, just check if not IsStudio then --have your yeilds in here

Its just a temporary thing I am doing just to be able to work on my project without going insane.

3 Likes

Or just comment it out. However that is a workaround, we need a fix for this.

Alternatively, I have a temporary button in my StarterGui that lets me call my datastore functions on click, so I can disable my BindToClose and still save my data.

Still, annoying.

3 Likes

Lol, ā€˜just comment it outā€™ well where is the over complexity in that?
I swear, sometimes the obvious escapes me :stuck_out_tongue:

2 Likes

Iā€™m having the same exact issue.

My datastore code literally hangs studio with BindToClose for 30+ seconds, sometimes even crashing it.
image

The other night this caused studio to actually EAT all my RAM when studio crashed.


Please excuse my custom windows theme

The code in question that causes the 30+ second hang:

game:BindToClose(function()
	while #PlayerData_Folder:GetChildren()>0 do
		PlayerData_Folder.ChildRemoved:wait()
	end
end)

And yes, ALL children of PlayerData_Folder are removed upon server shutdown, so it isnā€™t a mistake in my code causing this.

How to reproduce the bug:

Literally just press F5 to do a play solo session, have some `BindToClose` function that waits for all children of a data folder to be removed / all data to be written to datastores and studio will hang.

I also noticed that if you press F5, then press Shift+F5 within less than a second, studio will almost always crash. Why do I do this? Sometimes I see an obvious mistake in my code but I just pressed F5, so I quickly press shift+F5 to end the play solo session.

This has been an issue for months for me, and itā€™s really impacting development.

Please fix this as soon as possible, Iā€™m literally jumping through hoops around BindToClose while in studio to avoid this hang and potential crash.

5 Likes

I can confirm this happens with ALL yields. Simply a wait() will crash the BindToClose. @Fm_Trick, you may want to change the title accordingly.

3 Likes

It appears this is affecting more and more people dailyā€¦ (?) Would be good to get some staff input.

1 Like

Can confirm itā€™s been affecting me as well and was stumped for a while what was causing it this week.

3 Likes