{"record":{"id":"4946dc41cde8afda","repo":"discordjs/discord.js","slug":"timestamps-start-must-fit-into-a-unix-timestamp","errorCode":null,"errorMessage":"timestamps.start must fit into a unix timestamp","messagePattern":"timestamps\\.start must fit into a unix timestamp","errorType":"validation","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"packages/rpc/src/client.ts","lineNumber":550,"sourceCode":"\n\t/**\n\t * Sets the presence for the logged in user.\n\t *\n\t * @param activity - The rich presence to pass.\n\t * @param pid - The application's process ID. Defaults to the executing process' PID.\n\t * @remarks\n\t * Clients may only update their activity 5 times per 20 seconds.\n\t */\n\tpublic async setActivity(\n\t\tactivity: RPCSetActivityArgs['activity'] = {},\n\t\tpid: number | null = getPid(),\n\t\toptions?: RequestOptions,\n\t): Promise<unknown> {\n\t\tactivity.instance = Boolean(activity.instance);\n\n\t\tif (activity.timestamps) {\n\t\t\tif ('start' in activity.timestamps && isValidTimestamp(activity.timestamps.start)) {\n\t\t\t\tthrow new RangeError('timestamps.start must fit into a unix timestamp');\n\t\t\t}\n\n\t\t\tif ('end' in activity.timestamps && isValidTimestamp(activity.timestamps.end)) {\n\t\t\t\tthrow new RangeError('timestamps.end must fit into a unix timestamp');\n\t\t\t}\n\t\t}\n\n\t\treturn this.request(\n\t\t\tRPCCommands.SetActivity,\n\t\t\t{\n\t\t\t\tpid: pid ?? 0,\n\t\t\t\tactivity,\n\t\t\t},\n\t\t\toptions,\n\t\t);\n\t}\n\n\t/**","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/discordjs/discord.js/blob/a81ed8a306d37fdc746e26a634b6a42164ba2c8c/packages/rpc/src/client.ts#L532-L568","documentation":"setActivity() validates rich-presence timestamps and throws this RangeError when activity.timestamps.start is not a valid unix timestamp (per isValidTimestamp — outside the safe numeric range, e.g. milliseconds or NaN).","triggerScenarios":"Calling client.setActivity({ timestamps: { start: Date.now() } }) — passing milliseconds instead of seconds — or a string/NaN that fails the timestamp check.","commonSituations":"Using JavaScript's Date.now() (ms) directly, passing an ISO date string, or computing timestamps with Math.round missing.","solutions":["Convert to seconds: Math.floor(Date.now() / 1000)","Ensure the value is a finite number, not a string or Date object","Only set timestamps.start when you actually have a valid epoch-seconds value"],"exampleFix":"// before\nclient.setActivity({ timestamps: { start: Date.now() } });\n// after\nclient.setActivity({ timestamps: { start: Math.floor(Date.now() / 1000) } });","handlingStrategy":"validation","validationCode":"const startSec = Math.floor(Date.now() / 1000);\nif (!Number.isFinite(startSec) || startSec > 2 ** 53 - 1) throw new Error('start out of unix range');","typeGuard":"function isValidEpochSeconds(v: unknown): v is number {\n  return typeof v === 'number' && Number.isFinite(v) && v > 0 && v < 2 ** 53 - 1;\n}","tryCatchPattern":"try {\n  await client.setActivity(activity);\n} catch (err) {\n  if (err instanceof RangeError && err.message.includes('timestamps.start')) {\n    // fix timestamp units and retry\n  }\n}","preventionTips":["Always convert Date.now() (ms) to seconds before use","Never pass Date objects or ISO strings into timestamps","Centralize a toEpochSeconds() helper for all rich-presence timestamps"],"tags":["validation","rich-presence","unix-timestamp"],"backgroundTag":"invalid-timestamp","analyzedSha":"a81ed8a306d37fdc746e26a634b6a42164ba2c8c","analyzedAt":"2026-08-30T04:07:22.193Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}