Server authority (nextgen replication): undocumented 1024 kilobyte limit, crash if you exceed the limit in a large batch

Attribute total payload exceeds 1024 bytes
ReplicatedStorage.shared.packages.node_modules.@flamework.components.out.components:301 function getAttributes
ReplicatedStorage.shared.packages.node_modules.@flamework.components.out.components:575 function addComponent
ReplicatedStorage.shared.singletons.entity-manager:218 function RegisterEntity
ReplicatedStorage.shared.singletons.match-manager:441
ReplicatedStorage.shared.packages.Promise:172 function runExecutor
ReplicatedStorage.shared.packages.Promise:181
ReplicatedStorage.shared.packages.Promise:1254
ReplicatedStorage.shared.packages.Promise:172 function runExecutor
ReplicatedStorage.shared.packages.Promise:299

This limit should not exist. How are we supposed to be able to transmit a large statline? For example, this is what i’m trying to initialize my entities with on respawn:

{
    EntityId: symbol_no_entity_id,
    EntityOwnedBy: symbol_no_valid_owner,

    FacingDirection: Vector3.zero,
    MovingDirection: Vector3.zero,

    MaxHealth: 100,
    Health: 100,

    BaseDamage: 10,
    BaseDefense: 5,

    State: -1,

    CurrentAttack: symbol_no_framedata_id,
    PreviousAttack: symbol_no_framedata_id,

    TimeLastAttacking: -1,

    HitstopFrames: 0,
    HitstunFrames: 0,
    BlockstunFrames: 0,

    // THIRTY-TWO VALUES (16, but one for flat and percent)!!!
    // THIS ALONE IS ABOUT 256 BYTES!
    ...(
        Object.values(EntityStatistic).reduce((acc, v, k, a) => {
            const expr = <keyof typeof EntityStatistic>EntityStatistic[v];
            acc[`${expr}_FLAT`] = 0;
            acc[`${expr}_PERCENT`] = 0;

            return acc;
        }, {} as Record<`${keyof typeof EntityStatistic}_${"FLAT" | "PERCENT"}`, number>)
    ),

    BaseShieldSize: 4.5,
    ShieldMaximum: 150,
    ShieldCurrent: 150,

    ["SPEED_MOVEMENT_FLAT"]: 16,
    
    Upright: true,
    HasJumpLag: false,
    AttackedBy: symbol_no_entity_id,
};

If I try to set all of these attributes at once using a for loop, my studio crashes. If I have time (at minimum one second) before each :SetAttribute() call, the crash does not happen. Also, this was absurdly hard to find due to expanded table logging (or maybe just any log item that requires extra computation) loading out-of-order.

This is particularly infuriating because I encountered this exact same problem implementing my own rollback solution with unreliable remote events, but at least I could partially work around it by only sending changed attributes and compressing everything.

This is tied to NextGenerationReplication, not Server Authority itself (it seems).

Thank you for the report, it should absolutely not crash. The reasoning behind the current limit has been covered other threads, so I won’t rehash it here. Will post again when we have an update on this!

I’m investigating this right now. What was the instance you were assigning this to to cause it to crash?

I have this attached place that I created that assigns Attributes to the Humanoid Root Part every frame until it hits 50 Attributes, and it didn’t result in a crash.

AttributeCrash.rbxl (59.9 KB)

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

-- Configuration
local MAX_ATTRIBUTES = 51 -- Total attributes allowed per HumanoidRootPart
local ATTRIBUTE_PREFIX = "DynamicAttr_"

-- Helper to get a random value based on a type
local function getRandomValue(typeName)
	if typeName == "number" then
		return math.random(1, 1000)
	elseif typeName == "boolean" then
		return math.random() > 0.5
	elseif typeName == "string" then
		return "Value_" .. math.random(100, 999)
	end
	return nil
end

local function updateAndAddAttributes(character)
	local hrp = character:FindFirstChild("HumanoidRootPart")
	if not hrp then return end

	local currentAttributes = hrp:GetAttributes()
	local count = 0
	for _ in pairs(currentAttributes) do count += 1 end

	-- 1. Update existing attributes first
	for name, value in pairs(currentAttributes) do
		local vType = typeof(value)
		hrp:SetAttribute(name, getRandomValue(vType))
	end

	-- 2. Add a new one if we haven't hit the limit
	if count < MAX_ATTRIBUTES then
		local types = {"number", "boolean", "string"}
		local randomType = types[math.random(#types)]
		local newName = ATTRIBUTE_PREFIX .. (count + 1)

		hrp:SetAttribute(newName, getRandomValue(randomType))
		print(count)
	end
end

-- Connection to the Heartbeat (Runs every frame)
RunService.Heartbeat:Connect(function()
	for _, player in pairs(Players:GetPlayers()) do
		if player.Character then
			updateAndAddAttributes(player.Character)
		end
	end
end)

I was assigning this to a player character’s model. The attributes were:

export interface BaseEntityAttributes extends EntityStatistics
{
    readonly EntityId: string;
    readonly EntityOwnedBy: string;

    TimeLastAttacking: number,
    AttackedBy: string,

    MovingDirection: Vector3;
    FacingDirection: Vector3;

    MaxHealth: number;
    Health: number;

    BaseDefense: number;
    BaseDamage: number;

    BaseShieldSize: number;
    ShieldMaximum: number;
    ShieldCurrent: number;

    TimeBlocked?: number;
    TimeBlockReleased?: number;

    State: number;
    CurrentAttack: string;
    PreviousAttack: string;

    HitstopFrames: number;
    HitstunFrames: number;
    BlockstunFrames: number;

    // Whether the entity is forced to stay upright.
    Upright: boolean;
    HasJumpLag: boolean;
}

and

EntityStatistic.GENERIC_CURRENCY,

EntityStatistic.GENERIC_DAMAGE_FINAL,
EntityStatistic.GENERIC_DAMAGE_PHYSICAL,
EntityStatistic.GENERIC_DAMAGE_MAGICAL,
EntityStatistic.GENERIC_DAMAGE_TRUE,

EntityStatistic.GENERIC_DEFENSE_MAGICAL,
EntityStatistic.GENERIC_DEFENSE_PHYSICAL,
EntityStatistic.GENERIC_DEFENSE_FINAL,

EntityStatistic.GENERIC_ATTACK_SPEED_STARTUP,
EntityStatistic.GENERIC_ATTACK_SPEED_ACTIVE,
EntityStatistic.GENERIC_ATTACK_SPEED_RECOVERY,

EntityStatistic.GENERIC_SPEED_KNOCKBACK,
EntityStatistic.GENERIC_DISTANCE_KNOCKBACK,

EntityStatistic.GENERIC_TIME_WALLSPLAT,
EntityStatistic.SPEED_MOVEMENT,

EntityStatistic.POISE,

where the EntityStatistics interface is every EntityStatistic property emitted twice (flat/percentage), both as a number. In total, I was sending about 37 attributes. I think the problem is related to the payload size since I send quite a few numbers, not even including Vector3s and CFrames. When I removed some of the expensive values, there were no more crashes.

edit: Should note I was writing these attributes exactly when the character spawned.

When you say crash, do you actually mean your Studio crashed and not just the script?

What I would expect to happen is you see an error message that says something like “Invalid Attribute Removed”. Any help with a repro would be great, I’m still working on getting one on my end!

Here is what I did, I have a script like this

-- ServerScriptService/EntityAttributeManager
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

-- Configuration
local ATTRIBUTE_LIST = {
	-- BaseEntityAttributes
	EntityId = "string",
	EntityOwnedBy = "string",
	TimeLastAttacking = "number",
	AttackedBy = "string",
	MovingDirection = "Vector3",
	FacingDirection = "Vector3",
	MaxHealth = "number",
	Health = "number",
	BaseDefense = "number",
	BaseDamage = "number",
	BaseShieldSize = "number",
	ShieldMaximum = "number",
	ShieldCurrent = "number",
	State = "number",
	CurrentAttack = "string",
	PreviousAttack = "string",
	HitstopFrames = "number",
	HitstunFrames = "number",
	BlockstunFrames = "number",
	Upright = "boolean",
	HasJumpLag = "boolean",
	
	-- EntityStatistics
	GENERIC_CURRENCY = "number",
	GENERIC_DAMAGE_FINAL = "number",
	GENERIC_DAMAGE_PHYSICAL = "number",
	GENERIC_DAMAGE_MAGICAL = "number",
	GENERIC_DAMAGE_TRUE = "number",
	GENERIC_DEFENSE_MAGICAL = "number",
	GENERIC_DEFENSE_PHYSICAL = "number",
	GENERIC_DEFENSE_FINAL = "number",
	GENERIC_ATTACK_SPEED_STARTUP = "number",
	GENERIC_ATTACK_SPEED_ACTIVE = "number",
	GENERIC_ATTACK_SPEED_RECOVERY = "number",
	GENERIC_SPEED_KNOCKBACK = "number",
	GENERIC_DISTANCE_KNOCKBACK = "number",
	GENERIC_TIME_WALLSPLAT = "number",
	SPEED_MOVEMENT = "number",
	POISE = "number",
	
	-- Additional CFrames
	WorldContext = "CFrame",
	LastStanceRoot = "CFrame"
}

-- Helper to generate random values for testing
local function GetRandomValue(dataType)
	if dataType == "number" then
		return math.random(1, 100)
	elseif dataType == "string" then
		return "Value_" .. math.random(1000, 9999)
	elseif dataType == "boolean" then
		return math.random() > 0.5
	elseif dataType == "Vector3" then
		return Vector3.new(math.random(), math.random(), math.random())
	elseif dataType == "CFrame" then
		return CFrame.new(math.random(1, 10), 5, math.random(1, 10))
	end
	return nil
end

-- Initialize attributes on Spawn
local function SetupCharacter(character)
	for attrName, dataType in pairs(ATTRIBUTE_LIST) do
		character:SetAttribute(attrName, GetRandomValue(dataType))
	end
end

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(SetupCharacter)
end)

-- Update every frame
RunService.Heartbeat:Connect(function()
	for _, player in ipairs(Players:GetPlayers()) do
		local character = player.Character
		if character then
			for attrName, dataType in pairs(ATTRIBUTE_LIST) do
				-- Note: EntityId and EntityOwnedBy are often 'readonly' in logic, 
				-- but here we update them as requested.
				character:SetAttribute(attrName, GetRandomValue(dataType))
			end
		end
	end
end)

When I start the game I get the following script error every frame:

  10:27:58.382  Attribute total payload exceeds 1024 bytes  -  Server - Script:72
  10:27:58.383  Stack Begin  -  Studio
  10:27:58.384  Script 'Workspace.Script', Line 72 - function SetupCharacter  -  Studio - Script:72
  10:27:58.384  Stack End  -  Studio
  10:27:58.403  Attribute total payload exceeds 1024 bytes  -  Server - Script:88
  10:27:58.405  Stack Begin  -  Studio
  10:27:58.405  Script 'Workspace.Script', Line 88  -  Studio - Script:88
  10:27:58.405  Stack End  -  Studio
  10:27:58.618  Attribute total payload exceeds 1024 bytes  -  Server - Script:88
  10:27:58.619  Stack Begin  -  Studio
  10:27:58.620  Script 'Workspace.Script', Line 88  -  Studio - Script:88
  10:27:58.620  Stack End  -  Studio

But no crash, and the above is expected.

Complete studio crash, memory leak included. I have a short video showing the problem and the solution (please note how it absolutely DEVOURS my memory at 30 seconds in before I press the Stop button): https://files.catbox.moe/1jvhhy.mp4

Placefiles:
crossrealms-crashing-on-player-spawn.rbxl (2.2 MB)
crossrealms-without-the-crash.rbxl (2.2 MB)

Should be as simple as pressing F5 and watching the dark magic work. Could be that I have the client set the same attributes for every entity that is registered as well (on studio test player ready → player respawns alongside two dummies → all at that same time, those attributes are being set for the player character + two dummy entities)

Also, this problem does not happen at ALL when NextGenerationReplication is turned off.

Yeah that makes sense, it has to do with the Attribute limitation logic.

Thanks for the repro level. Yesterday I found an entirely different bug that was a deadlock on certain attribute sending above payload limit (when they would sneak through). Based on testing your repro level, this is the same bug.

I just encounter this bug when turning on NextGenerationReplication. Studio crash, couldn’t really debug anything.

Do you have a repro you can share?

I thought I fixed this on latest version of Studio as of last Thursday.

marking as fixed since no further responses

I don’t have any repo, but the bug is from the setting a lot of attribute on the player instance. Whenever I turned on the settings, the error returns. I traced it back to the line where I set attribute to the player instance.

“Attribute total payload exceeds 1024 bytes”