What happens if you await inside _enter_tree() or _ready()?

Godot Version

v4.3.stable.flathub [77dcf97d8]

Question

In godot, what happens if I have an await inside _enter_tree or _ready?
I know that the code below it in the method itself is blocked, but what else? Will nodes be processed, respond to input, etc?

  1. Will other nodes await?
  2. Will at least child nodes await?
  3. Will at least other callbacks in the node itself (process, input, click events, etc) await?
  4. Will at least _ready await for an await in _enter_tree of the same node?

I asked ChatGPT about this, and it said it doesn’t block execution of other nodes, not even child nodes, but does block other events (like process) on the node itself. Is this correct or not?

For example, if I need await to initialize a member field on the node, do I have to check it for null in all other methods that use it?

1 Like

It does not block other nodes or processes. await only blocks calling functions if the calling function uses await on the call, which does not happen for overriden functions.

1 Like

So I guess that means (1) and (2) are false.
What about (3) and (4)?

1 Like

None will await

It’s a fairly common problem posted here to use await in _process expecting it to run once.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.