{"record":{"id":"5cce6256981f50eb","repo":"discordjs/discord.js","slug":"request-timed-out","errorCode":null,"errorMessage":"Request timed out","messagePattern":"Request timed out","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/client.ts","lineNumber":304,"sourceCode":"\t\t\t\t\tnonce,\n\t\t\t\t\tnotFound: data.not_found ?? null,\n\t\t\t\t\tpresences: data.presences ?? null,\n\t\t\t\t\tchunkIndex: data.chunk_index,\n\t\t\t\t\tchunkCount: data.chunk_count,\n\t\t\t\t};\n\n\t\t\t\tif (data.chunk_index >= data.chunk_count - 1) break;\n\n\t\t\t\t// eslint-disable-next-line require-atomic-updates\n\t\t\t\ttimer = createTimer(controller, timeout);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && error.name === 'AbortError') {\n\t\t\t\tif (error.cause instanceof GatewayRateLimitError) {\n\t\t\t\t\tthrow error.cause;\n\t\t\t\t}\n\n\t\t\t\tthrow new Error('Request timed out');\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tcleanup();\n\t\t}\n\t}\n\n\t/**\n\t * Requests guild members from the gateway.\n\t *\n\t * @see {@link https://discord.com/developers/docs/topics/gateway-events#request-guild-members}\n\t * @param options - The options for the request\n\t * @param timeout - The timeout for waiting for each guild members chunk event\n\t * @example\n\t * Requesting specific members from a guild\n\t * ```ts\n\t * const { members } = await client.requestGuildMembers({ guild_id: '1234567890', user_ids: ['9876543210'] });","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/discordjs/discord.js/blob/a81ed8a306d37fdc746e26a634b6a42164ba2c8c/packages/core/src/client.ts#L286-L322","documentation":"This error is thrown by the gateway REQUEST_GUILD_MEMBERS flow when the library's timeout elapses before enough guild member chunk responses arrive. The library sends a Gateway Request Members command and awaits chunk dispatches; if the gateway does not reply (or not fully) within the timeout, the AbortController fires, the iterator sees an AbortError, and it rethrows a generic 'Request timed out' error. It means the operation was abandoned client-side, not that Discord rejected the request.","triggerScenarios":"Calling requestGuildMembers when the gateway connection is degraded or reconnecting, when the request targets a guild the bot is not in on that shard, when fetching all members of a very large guild and not all chunks arrive before the timeout, or when awaiting presences that were never requested.","commonSituations":"Bots doing member caching on startup across many large guilds; network hiccups or gateway RESUME/RESUMING mid-request; accidentally requesting a guild the shard is not subscribed to; overly short timeout configured in the call.","solutions":["Check gateway connectivity (shard Events) and ensure the client is fully ready (READY/GUILD_CREATE) before calling requestGuildMembers.","Increase the timeout passed to requestGuildMembers and consume the full iterator instead of breaking early.","Verify the guild id is correct and the bot is a member of that guild on the connected shard.","Retry the request only after confirming the shard is not reconnecting; requests during RESUME are unreliable.","Narrow the request (userIds, or query+limit) so fewer chunks are needed before the timeout."],"exampleFix":"// before\nconst members = await client.guilds.cache.get(id).members.fetch({ query: '' });\n// after\nconst guild = client.guilds.cache.get(id);\nif (!guild) throw new Error('Bot is not in guild');\nconst members = await guild.members.fetch({ query: '', time: 120_000 }); // longer timeout","handlingStrategy":"try-catch","validationCode":"if (!client.isReady()) throw new Error('Client not ready');\nconst guild = client.guilds.cache.get(guildId);\nif (!guild) throw new Error(`Bot not in guild ${guildId}`);","typeGuard":"function isKnownGuild(client, id) {\n  return typeof id === 'string' && /^\\d{17,20}$/.test(id) && client.guilds.cache.has(id);\n}","tryCatchPattern":"try {\n  await client.requestGuildMembers({ guild: guildId, query: '', limit: 0 });\n} catch (err) {\n  if (err.message === 'Request timed out') {\n    // shard degraded: schedule retry after checking shard status\n    return retryLater(guildId);\n  }\n  throw err;\n}","preventionTips":["Wait for client ready and stable shards before requesting members.","Use longer/custom timeouts for large guilds.","Narrow requests with userIds or limit+query to reduce chunk count.","Monitor shard reconnect events and defer member requests until resume completes.","Prefer guild.members.fetch on guilds already fully cached."],"tags":["gateway","timeout","discord-api"],"backgroundTag":"gateway-request-timeout","analyzedSha":"a81ed8a306d37fdc746e26a634b6a42164ba2c8c","analyzedAt":"2026-08-30T04:07:22.193Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}