godotengine / godotengine/godot

`IsInstanceValid` called before the end of the frame returns true on an object that called `QueueFree`

Open
#99,239 4 comments 2 reactions 0 assignees View on GitHub
breaks compat discussion topic:core
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

tested on v4.3.stable.mono.official

### System information

Windows 10 - Godot v4.3.stable.mono.official

### Issue description

If we call `node.QueueFree()`, `IsInstanceValid(node)` should return `false` even before the end of the frame.
I can't think of a reason why would anyone need to have `IsInstanceValid(node)` returning true after a `node.QueueFree()` call.

### Steps to reproduce

1. Create a node,
2. Print out `IsInstanceValid`
3. QueueFree the node
4. Print out `IsInstanceValid`

It prints out
```
true
true
```

and I think it must print out

```
true
false
```

### Minimal reproduction project (MRP)

```
ColorRect n = new ColorRect();
AddChild(n);
GD.Print(IsInstanceValid(n));
n.QueueFree();
GD.Print(IsInstanceValid(n));
```

Contributor guide

Open the contributing guide

Research direction

Start with the minimal reproduction shown in the issue and run it against Godot v4.3.stable.mono.official to confirm the lifecycle behavior around QueueFree and IsInstanceValid. Trace the engine's object-deletion and validity checks, then verify that the documented expected output is produced without breaking queued deletion semantics.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.