Is code after task.spawn() guaranteed to execute after the code in the spawn?

task.spawn(print, 1)
print(2)

Is that guaranteed to print in this order:

1
2

Or is that a race condition?

task.spawn() will run first and then print() will

unless im being stupid and should go to bed

task.spawn will be called before the print, but will the first print being called by task.spawn with 1 run before the 2nd print being called with 2?

Yes. The only scenario where task.spawn wouldn’t execute is if you’re at a recursion depth of 200. Otherwise, it’s immediate and the output would look like this:

1
2

if you’re not sure, then you can use task.defer, but it might vary really, while developing my signal module i encoutered a problem where sometimes if the game’s memory usage is higher due other scripts, my :Once() function didn’t worked, this is why i implemented :safeOnce() and :call() that wouldn’t use task library, tho it’s just an observation