{"record":{"id":"45db42019139fd1f","repo":"toeverything/AFFiNE","slug":"failed-to-fetch-snapshot","errorCode":null,"errorMessage":"Failed to fetch snapshot","messagePattern":"Failed to fetch snapshot","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/frontend/core/src/components/affine/page-history-modal/data.ts","lineNumber":91,"sourceCode":"};\n\nconst snapshotFetcher = async (\n  [fetchService, workspaceId, pageDocId, ts]: [\n    FetchService,\n    workspaceId: string,\n    pageDocId: string,\n    ts: string,\n  ] // timestamp is the key to the history/snapshot\n) => {\n  if (!ts) {\n    return null;\n  }\n  const res = await fetchService.fetch(\n    `/api/workspaces/${workspaceId}/docs/${pageDocId}/histories/${ts}`\n  );\n\n  if (!res.ok) {\n    throw new Error('Failed to fetch snapshot');\n  }\n\n  const snapshot = await res.arrayBuffer();\n  if (!snapshot) {\n    throw new Error('Invalid snapshot');\n  }\n  return snapshot;\n};\n\n// attach the Page shown in the modal to a temporary workspace\n// so that we do not need to worry about providers etc\n// TODO(@Peng): fix references to the page (the referenced page will shown as deleted)\n// if we simply clone the current workspace, it maybe time consuming right?\nconst docCollectionMap = new Map<string, Workspace>();\n\n// assume the workspace is a cloud workspace since the history feature is only enabled for cloud workspace\nconst getOrCreateShellWorkspace = (\n  workspaceId: string,","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/core/src/components/affine/page-history-modal/data.ts#L73-L109","documentation":"snapshotFetcher throws when the history-snapshot API (/api/workspaces/:id/docs/:docId/histories/:ts) responds with a non-ok status, meaning the requested doc snapshot for that timestamp could not be retrieved from the server.","triggerScenarios":"Thrown in the page history snapshotFetcher when the GET request to /api/workspaces/:id/docs/:id/histories/:ts returns a non-OK response.","commonSituations":"Seen when opening page version history and the server rejects or cannot serve a snapshot. Check network/session and retry; the version may no longer exist.","solutions":["Retry fetching the page history snapshot; check network and server availability.","Verify the workspace/doc ids used for the history request."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}