{"record":{"id":"c1d5bf563780b12a","repo":"discordjs/discord.js","slug":"shardingnochildexists","errorCode":"ShardingNoChildExists","errorMessage":"ShardingNoChildExists","messagePattern":"ShardingNoChildExists","errorType":"error_code","errorClass":"DiscordjsError","httpStatus":null,"severity":"error","filePath":"packages/discord.js/src/sharding/Shard.js","lineNumber":291,"sourceCode":"        resolve(this);\n      }\n    });\n  }\n\n  /**\n   * Fetches a client property value of the shard.\n   *\n   * @param {string} prop Name of the client property to get, using periods for nesting\n   * @returns {Promise<*>}\n   * @example\n   * shard.fetchClientValue('guilds.cache.size')\n   *   .then(count => console.log(`${count} guilds in shard ${shard.id}`))\n   *   .catch(console.error);\n   */\n  async fetchClientValue(prop) {\n    // Shard is dead (maybe respawning), don't cache anything and error immediately\n    if (!this.process && !this.worker) {\n      throw new DiscordjsError(ErrorCodes.ShardingNoChildExists, this.id);\n    }\n\n    // Cached promise from previous call\n    if (this._fetches.has(prop)) return this._fetches.get(prop);\n\n    const promise = new Promise((resolve, reject) => {\n      const child = this.process ?? this.worker;\n\n      const listener = message => {\n        if (message?._fetchProp !== prop) return;\n        child.removeListener('message', listener);\n        this.decrementMaxListeners(child);\n        this._fetches.delete(prop);\n        if (message._error) reject(makeError(message._error));\n        else resolve(message._result);\n      };\n\n      this.incrementMaxListeners(child);","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/discordjs/discord.js/blob/a81ed8a306d37fdc746e26a634b6a42164ba2c8c/packages/discord.js/src/sharding/Shard.js#L273-L309","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nconst guilds = await shard.fetchClientValue('guilds.cache.size');\n// after\nif (!shard.process && !shard.worker) await shard.respawn();\nconst guilds = await shard.fetchClientValue('guilds.cache.size');","handlingStrategy":"retry","validationCode":"async function fetchClientValueSafe(shard, prop) {\n  if (!shard.process && !shard.worker) await shard.respawn();\n  return shard.fetchClientValue(prop);\n}","typeGuard":"function childIsAlive(shard) { return Boolean(shard.process || shard.worker); }","tryCatchPattern":"try {\n  return await shard.fetchClientValue(prop);\n} catch (err) {\n  if (err.code === 'ShardingNoChildExists') {\n    await shard.respawn();\n    return shard.fetchClientValue(prop);\n  }\n  throw err;\n}","preventionTips":["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"],"tags":["sharding","discordjs","ipc","dead-child-process"],"backgroundTag":"shard-child-not-running","analyzedSha":"a81ed8a306d37fdc746e26a634b6a42164ba2c8c","analyzedAt":"2026-08-30T04:07:22.193Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}