comfyui-client
comfyui-client copied to clipboard
Improve: lazy polling
Currently, our polling logic is tied to the lifecycle of the example runner and runs continuously using setInterval.
In fact, this is unnecessary—because for a client, if it doesn't need to monitor ComfyUI's execution status, polling isn't required at all. It should only be activated when a task is being executed.
To implement this change, we need to build a Polling Manager that decouples the polling lifecycle from the polling request logic.
This will allow us to start and stop polling as needed, only when a client explicitly requires it.
https://github.com/StableCanvas/comfyui-client/blob/8e236f69cc95ad059d40407f97d5bdc31805f0a0/src/client/WsClient.ts#L250-L268