Status poller not initialized
2 min read
getStatusPoller() throws when the module-level instance has not been created.
export function getStatusPoller(): StatusPoller {
if (!pollerInstance) {
throw new Error('Status poller not initialized. Call initStatusPoller first.');
}
return pollerInstance;
}
The family
Three siblings throw the same shape: the orchestrator client, the orchestrator service, and this. Each names the specific initialiser to call, which matters when three of them fail the same way — "not initialized" alone would leave you guessing which subsystem.
What causes it
Import order. Something reached for the poller during module evaluation, before the application's startup ran the init functions.
A missing init on one path. The main entry point initialises; a script, a test, or a background job does not.
A failed init that was swallowed. Initialisation threw, something caught and logged it, and the process continued to the first use.
The sharper failure this pattern can hide
A module-level singleton is only a singleton within one module instance. If a
bundler emits several copies of the module — separate entry points without code
splitting, for example — each copy gets its own pollerInstance, and code
holding one is not talking to the other.
That produces no error at all. Everything appears initialised and the object doing the work is not the object being observed. This exact failure has bitten this codebase before, in the dispatch coordinator, where it presented as agents that never started while dispatch reported success.
If this error is absent but the poller seems inert, that is where to look.
How to fix it
Call the named initialiser during application startup, before anything can reach for the instance. If it is already being called, check whether the code that throws runs at module-evaluation time rather than inside a request or job — that ordering is the usual culprit.
