godotengine / godotengine/godot

Function _exit_tree() is not called properly in editor mode

Open
#98,752 8 comments 2 reactions 0 assignees View on GitHub
bug topic:core
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

v4.3.stable

### System information

Godot v4.3.stable (77dcf97d8) - Windows 10.0.22621 - Vulkan (Mobile) - dedicated NVIDIA GeForce RTX 4070 Ti (NVIDIA; 32.0.15.6094) - 13th Gen Intel(R) Core(TM) i5-13600KF (20 Threads)

### Issue description

```gdscript
extends Node2D

func _enter_tree() -> void:
print("_enter_tree")
pass

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
print("_ready")
pass # Replace with function body.

func _exit_tree() -> void:
print("_exit_tree")
pass

```
I expect the print result:
```gdscript
_enter_tree
_ready
_exit_tree
```
But currently the print result:
```gdscript
_enter_tree
_ready
```

### Steps to reproduce

Run the project in the editor and close the window.
Check the print results.

### Minimal reproduction project (MRP)

[bugtest.zip](https://github.com/user-attachments/files/17605660/bugtest.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.