Task.sync/desync throwing a warning unexpectedly

It doesn’t seem to affect actual code execution but it throws a warning of task.synchronize/desynchronize should only be called from a script that is a descendant of an Actor whilst the script is currently inside of an Anctor.


The only reason I could think this occurs is because I create the actor and parent the script inside the actor on execution instead of it being pre confined to an Actor. (If this isn’t supported behaviour do let me know).

For extra information: The code is being executed inside a Local Script that gets manually deployed into the client from the server.

Expected behavior

I would expect this warning to not occur. However the script seems to function like normal. For example when supposedly in parallel it didn’t let me use :GetService() which is expected beaviour despite this warning.
For example:

I can only theorise that a check to see if the code was within an actor in the beginning doesn’t get updated when a script parents itself or becomes a descendant of an actor.

I am pretty sure I understand the issue here. The problem is that normally we expect a script under an actor to have started execution under that actor. This ensures that the Luau threads for the script are all running on a Luau VM that is able to run Parallel code. If a script started executing without being under an Actor initially, then the threads will be on a different VM.

Most likely our check for calling desynchronize is looking at the currently executing thread to see if it is safe to run in parallel. Since the thread is associated with a “non-parallel” VM, the check fails and you get an error message. The error is trying to provide some useful information about the problem without overwhelming you with details. But unfortunately, in this case, some more details would be required to fully explain why the problem is occuring.

You can solve this problem by creating the Actor and parenting the script to it before it begins execution. It’s usually easiest to have a separate script that manages that process.

2 Likes

Thats what I understand with this bug.

My main question regarding this is would the code still run in parallel? Since these are just warnings they don’t stop script execution and I’m just wondering if the code after task.desync.. does actually run in parallel.

Also whether this will be looked at or fixed or left as intended since it doesn’t really break anything.

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