BindToClose 100% Infinite Yield


As of two hours ago I have been getting:

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")

	ds:SetAsync("akey", {})
  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)

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

OrderedDataStore yields infinitely when closing a game
~30 second delay after running game in studio
Accurate Play Solo BindToClose DataStore doesn't save
FireClient not triggering through a PlayerRemoving event?
Saving data to Datastore taking a long time on Studio test
BindToClose extended yield w/ coroutine.yield()
SetAsync stopping script indefinitely
XP System DataStore
Warning regarding GameAnalytics SDK

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


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.


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


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


Just tested, this is only in Studio thankfully.


How did you confirm?


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.


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


Still an issue that is halting proper development.


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.


Can confirm I’m having this issue too


This needs to get fixed, absolutely destroying dev time


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.


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.


Lol, ‘just comment it out’ well where is the over complexity in that?
I swear, sometimes the obvious escapes me :stuck_out_tongue:


I’m having the same exact issue.

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

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:

	while #PlayerData_Folder:GetChildren()>0 do

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.


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.


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


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