Description
I'm the author of DCli which utilises waitFor to synchronously spawn processes.
With the deprecation of waitFor I'm currently stuck without a way to maintain the current api.
This issue tracking the deprecation of waitFor is here:
The core issue is that I need to spawn an isolate synchronously.
I'm not looking for the isolate to run to completion, rather just the ability to start the isolate synchronously.
With the current api
final isolate = Isolate.spawn<Args>(_runProcess, Args(commandToRun, mailbox));
/// The following code creates a dead lock as the isolate hasn't started and so doesn't
/// put anything into the mailbox.
mailbox.take(); // sync call that doesn't return util the isolate starts and puts a message into the mailbox
final isolate = Isolate.spawnSync<Args>(_runProcess, Args(commandToRun, mailbox));
/// I'm now guaranteed the isolate is running which means it will eventually place something in the mailbox.
mailbox.take(); // sync call.
I've tried an number of paths to get around the spawn issue but it appears that if you make a sync call (e.g. mailbox.take) immediately after calling Isolate.spawn then the spawned isolate doesn't start. I assume the current spawn logic is relying on a async call to be given processing time to start.
Unless I'm wrong about how spawn works, I've hit a brick wall in migrating dcli off of waitfor. I have resolutions for all of the other code except this rather critical piece.
I need this enhancement before waitFor is removed from the dart api.