Race Condition

2025/12/27

Type
Learning Resource
Format
Glossary Article
Version
General
Subject Tags
Code
Assets
All else
Copyright 2016-2026, GDQuest
Created
2026/02/16
Updated
2025/12/27

Race Condition

A race condition is a situation in which two or more parts of a software are reading or writing shared data, and the final result depends on which process finishes or starts first. Race conditions happen when the order of execution is not guaranteed; that's why it's called a "race". Initially, the term applied to threads, but it's now used more broadly to describe any situation where the final state of a system depends on the order of operations.

The classic example is a networked application where two clients are trying to update the same record in a database. If the clients don't lock the record before updating it, the final state of the record will depend on which client updates it last.

Race conditions are complicated to debug, as they are often hard to reproduce.

Race conditions can happen because:

Because of the elusive and non-deterministic behavior of race conditions, they're sometimes amusingly called "heisenbugs" after the Heisenberg Uncertainty Principle in physics.

While not strictly correct, the term can also be used for deterministic, reproducible bugs that still go against your expectations. For example, if you try to access a node that doesn't exist yet in GDScript:

func _init():
  var node := get_node("Sprite2D")

Sprite2D doesn't exist yet in the _init() function; it is only accessible in the _ready() function. In this case, the error is because of a programmer mistake due to a misunderstanding of the lifecycle of a node. Nonetheless, because the mistake isn't obvious and hard to predict unless you know Godot well, people will still often call it a "race condition".

Become an Indie Gamedev with GDQuest!

Don't stop here. Step-by-step tutorials are fun but they only take you so far.

Try one of our proven study programs to become an independent Gamedev truly capable of realizing the games you’ve always wanted to make.

Nathan

Founder and teacher at GDQuest
  • Starter Kit
  • Learn Gamedev from Zero
Check out GDSchool

You're welcome in our little community

Get help from peers and pros on GDQuest's Discord server!

20,000 membersJoin Server

Contribute to GDQuest's Free Library

There are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!