How to Correctly Delete an object waiting for an await in Godot 4

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DaZel77

I have a room system in my game that deletes the past room when the player walks through a door, but sometimes I get an error resume: Resumed function ‘_on_death_timer_timeout()’ after await, but class instance is gone. (_on_death_timer_timeout just queue_frees the node after a set amount of time). Is there any way to force it to finish up then delete?

:bust_in_silhouette: Reply From: Adab

I have never worked with await in godot so I am not sure if this could be possible but I’d say just set the visibility to false on your method _on_death_timer_timeout(), wait for the await to be finished by sending a signal afterwards and when that signal triggers then you use queue_free()