Deleting body in multiplayer resulting in error

Godot Version



I have a multiplayer running and its functioning normally. Recently I discovered that when someone disconnects it gives me this error :

E 0:00:13:0931   _remove_node_cache: Condition "!pinfo" is true. Continuing.
  <C++ Source>   modules/multiplayer/scene_cache_interface.cpp:57 @ _remove_node_cache()

It is centered around my disconnect function and I don’t know why it suddenly krept up.

this is what my spawning code as a whole looks like

extends Node3D

var random_location := 5

func _ready():
	print("level ready")
	if not multiplayer.is_server():
	for player_id in multiplayer.get_peers():
	if not OS.has_feature("dedicated_server"):

func peer_connected(player_id:int):

func peer_disconnect(player_id:int):

func add_player(player_id:int):
	print("add player:"+str(player_id))
	var player=preload("res://Assets/player/Bodies/player_drone_body.tscn").instantiate()
	player.player=player_id ##!!the variable after player is referancing player property!!##
	var player_position :=Vector2.from_angle(randf()*2*PI)

func delete_player(player_id:int):
	if not $Portal.has_node(str(player_id)):

func _exit_tree():
	if not multiplayer.is_server():

I have other questions related to:
^^^ I tried putting the code related to multiplayer in an autoloader but everything refused to work.

Technically the code works as-is. It deletes the body and the game continues forward as normal. I tried some prints to see if its somehow pinging the disconnect function twice but it looks like only does it on the single attempt. The session that is giving the error is the host. I turned off the disconnect function and the body continues to stay so the disconnect is the only thing messing with the bodies removal!? I wonder if its a timing thing or something. I am curious on thoughts. It does work, im just confused why the error started appearing and what it means? other than simply “im trying to delete a node that doesnt exist”.

Full disclosure I’ve done zero godot MP. But it’s my coffee break here and I have some thoughts anyways.

If I had to guess, the node in question still technically exists, but is no longer valid.

So where you check if $Portal has the node, get the node and cache the result, then test if the result is valid with is_instance_valid(), and if it is, then queue_free it.

Alternatively I suspect that calling delete_player itself deferred, and not just the queue_free end result may accomplish same thing. Checking if valid feels cleaner to me though.

gl! Now i wanna code some MP stuff, lol.