-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SaveAsync clones tables before giving them to BeforeSave #117
Labels
Comments
Masken8
changed the title
Putting a table with circular references in the cache causes a stack overflow
Saving a table with circular references causes a stack overflow
Dec 30, 2020
Masken8
changed the title
Saving a table with circular references causes a stack overflow
SaveAsync clones tables before giving them to BeforeSave
Dec 30, 2020
Can you provide an MVCE? |
Edit: Place file https://www.roblox.com/games/6167461405/DS2MVCE This should do it local Players = game:GetService("Players")
local DataStore2 = require(PathToDataStore2)
local MyClass = {}
MyClass.__index = MyClass
function MyClass.new(obj2, stuff)
local self = {
object2Ref = obj2,
stuff = stuff
}
setmetatable(self, MyClass)
return self
end
local MyClass2 = {}
MyClass2.__index = MyClass2
function MyClass2.new()
local self = {
object1Ref = nil,
}
setmetatable(self, MyClass2)
return self
end
function Serialize(deserialized)
local serializedTable = {}
for _, v in pairs(deserialized) do
table.insert(serializedTable, {
stuff = v.stuff,
})
end
return serializedTable
end
DataStore2.PatchGlobalSettings({
SavingMethod = "Standard",
});
DataStore2.Combine("Data", "CircularReferenceTable");
Players.PlayerAdded:Connect(function(player)
local CircularReferenceTableStore = DataStore2("CircularReferenceTable", player)
local Object2 = MyClass2.new()
local Object = MyClass.new(Object2, "asdf")
Object2.object1Ref = Object
CircularReferenceTableStore:BeforeSave(Serialize)
CircularReferenceTableStore:Set({ Object })
CircularReferenceTableStore:Save()
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The data I'm putting in the cache is a table of metatable based objects and those objects reference objects that reference them.
Cause: Save clones the table and then gives it to
BeforeSave
.Stack Trace:
BeforeSave: Yes
BeforeInitialGet: Yes
The tables output by my
BeforeSave
andBeforeInitialGet
do not include any circular references.Saving Method:
Standard
Do note that I am using https://github.com/osyrisrblx/rbx-datastore2 but it's using the same underlying code. The script that handles this seems to be up to date.
The text was updated successfully, but these errors were encountered: