Skip to content

Regression in 2.9.2 (PR #3878): NetworkList<T>.Add() during server-side OnNetworkSpawn delivers duplicate entry to joining client #3999

Description

@SquidyLLC

Bug

When a NetworkList<T>.Add() is performed on the server during a newly-spawned NetworkObject's OnNetworkSpawn, the joining client receives the new entry twice — once via the spawn snapshot (WriteFieldSynchronization) and again as a queued delta (WriteDelta → EventType.Add). Other peers see the list correctly.

Why it happens

PR #3878 deleted this override from Runtime/NetworkVariable/Collections/NetworkList.cs:

internal override void OnSpawned()
{
    if (IsDirty() && CanSend() && m_NetworkObject.IsSpawnAuthority)
    {
        UpdateLastSentTime();
        ResetDirty();
        SetDirty(false);
    }
    base.OnSpawned();
}

Its own comment said it existed "to prevent duplicate entries from being sent (i.e. CreateObjectMessage will contain the changes so we don't need to send a proceeding NetworkVariableDeltaMessage)."

PR #3878 moved this logic into NetworkVariableBase.InternalOnSpawned() intending to make it universal, but the new predicate adds a CanWrite() check that wasn't in the original, and that check is what's now excluding server-write NetworkList in the spawn-time path.

Fix

Restore NetworkList<T>.OnSpawned(), or change the predicate in NetworkVariableBase.InternalOnSpawned() to match the deleted version (IsDirty() && CanSend() && IsSpawnAuthority).

Versions tested

  • 2.9.1 Works Properly
  • 2.9.2 and 2.11.2 Broken. Same Issue.

Activity

  1. EmandM commented on May 25, 2026

    @EmandM
    Member

    Thank you for reporting. For our information, why did you close this issue?

  2. SquidyLLC commented on May 25, 2026

    @SquidyLLC
    Author

    Thank you for reporting. For our information, why did you close this issue?

    I closed the issue because I was able to reproduce the issue again on v2.9.1, which meant that I was completely wrong as to what exactly was causing the issue in the first place. I'll make another reply to this issue explaining what exactly is happening.

  3. SquidyLLC commented on May 25, 2026

    @SquidyLLC
    Author

    For context, we're on client-server topology, not distributed. Server-side code modifies a NetworkList (server-write permissions) inside Player.OnNetworkSpawn (The connected client networkObject) for a just-connecting client, so the Add fires on the same tick that client is connecting. The joining client then receives the initial snapshot of the NetworkBehaviour holding that list after the Add already committed on the server, so the snapshot already contains the new entry. Then, they also receive the queued NetworkVariableDeltaMessage broadcasting that same Add (deferred locally until the NetworkObject finishes spawning, then replayed inside the same NonAuthorityLocalSpawn frame). The result is the joining client's list has the entry twice. Every other client gets only the delta and is correct. Server is correct.

  4. EmandM commented on May 25, 2026

    @EmandM
    Member

    We have automated tests in NetworkListTests.OwnerWriteTests that cover this case and check that adding during OnNetworkSpawn works as expected. You can run the test by cloning this repo and opening the testproject.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions