fix: Don't accept invalid connections in UnityTransport.Send #3382
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This avoids the error message reported in MTTB-1143.
The
UnityTransport.Send
method would happily accept invalid or stale connections, which would lead to the allocation of aBatchedSendQueue
structure and to an error message when the batched sends are passed on to the driver.In MTTB-1143 we'd get a send on client ID 0, but that's not a valid client ID in
UnityTransport
. My guess is that there's something somewhere (possibly in Boss Room) triggering a send to the server after the connection has closed (which revertsUnityTransport.ServerClientId
to its default value of 0). Of course, ideally there'd never be such a send-after-disconnect and that's what should be ultimately addressed. But the bug is quite hard to reproduce, so as a stopgap until we have something better I'm making a fix that only avoids the last and more user-visible consequences of the issue.Changelog
UnityTransport
where the transport would accept sends on invalid connections, leading to a useless memory allocation and confusing error message.Testing and Documentation