discordjs/discord.js · error · DiscordjsError
ShardingNoChildExists
ShardingNoChildExists
Error message
ShardingNoChildExists
What it means
ShardingNoChildExists is thrown by Shard.fetchClientValue() when the shard has neither a process nor a worker attached, i.e., the child client is dead or was never spawned. Since there is no child to message, the library cannot request the client property and errors immediately without caching the promise.
Source
Thrown at packages/discord.js/src/sharding/Shard.js:291
resolve(this);
}
});
}
/**
* Fetches a client property value of the shard.
*
* @param {string} prop Name of the client property to get, using periods for nesting
* @returns {Promise<*>}
* @example
* shard.fetchClientValue('guilds.cache.size')
* .then(count => console.log(`${count} guilds in shard ${shard.id}`))
* .catch(console.error);
*/
async fetchClientValue(prop) {
// Shard is dead (maybe respawning), don't cache anything and error immediately
if (!this.process && !this.worker) {
throw new DiscordjsError(ErrorCodes.ShardingNoChildExists, this.id);
}
// Cached promise from previous call
if (this._fetches.has(prop)) return this._fetches.get(prop);
const promise = new Promise((resolve, reject) => {
const child = this.process ?? this.worker;
const listener = message => {
if (message?._fetchProp !== prop) return;
child.removeListener('message', listener);
this.decrementMaxListeners(child);
this._fetches.delete(prop);
if (message._error) reject(makeError(message._error));
else resolve(message._result);
};
this.incrementMaxListeners(child);View on GitHub (pinned to a81ed8a306)
Solutions
- Check (shard.process || shard.worker) before calling fetchClientValue, or guard with shard.ready
- Await manager.spawn() and shard 'ready' events before fetching values
- Wrap in try/catch and retry after respawn completes (listen for manager 'shardReady'/'shardResume')
- If respawn is in flight, wait for it to resolve before issuing fetchClientValue
Example fix
// before
const guilds = await shard.fetchClientValue('guilds.cache.size');
// after
if (!shard.process && !shard.worker) await shard.respawn();
const guilds = await shard.fetchClientValue('guilds.cache.size'); Defensive patterns
Strategy: retry
Validate before calling
async function fetchClientValueSafe(shard, prop) {
if (!shard.process && !shard.worker) await shard.respawn();
return shard.fetchClientValue(prop);
} Type guard
function childIsAlive(shard) { return Boolean(shard.process || shard.worker); } Try / catch
try {
return await shard.fetchClientValue(prop);
} catch (err) {
if (err.code === 'ShardingNoChildExists') {
await shard.respawn();
return shard.fetchClientValue(prop);
}
throw err;
} Prevention
- Wait for manager 'shardReady' events before issuing client-value fetches
- Check shard readiness/child existence before IPC calls
- Avoid fetching values while respawn() is in flight - await it first
- Handle shard death events ('shardDisconnect'/'shardDeath') by pausing dependent logic
When it happens
Trigger: Calling shard.fetchClientValue(prop) after the child process/worker exited (crash, kill(), or during respawn window); calling it before manager.spawn(); racing fetchClientValue with respawn() so the child is gone when the guard runs.
Common situations: Querying guild counts from a shard that crashed; IPC handlers in the manager responding to requests while a shard is respawning; startup ordering bugs where the manager broadcasts to shards before spawn() finishes.
Related errors
- ShardingProcessExists
- ShardingWorkerExists
- ShardingShardMiscalculation
- ClientInvalidOption
- Shard ${shardId} not found
AI-assisted analysis of discordjs/discord.js@a81ed8a306 (2026-08-30).
Data as JSON: /api/errors/c1d5bf563780b12a.
Report an issue: GitHub.