Graphical PDS migrator for AT Protocol

Update MigrationProgress.tsx

Changed files
+35 -5
islands
+35 -5
islands/MigrationProgress.tsx
··· 196 196 console.log("Starting data migration..."); 197 197 198 198 try { 199 + console.log("Data migration: Sending request to /api/migrate/data"); 199 200 const dataRes = await fetch("/api/migrate/data", { 200 201 method: "POST", 201 202 headers: { "Content-Type": "application/json" }, 202 203 }); 203 204 204 - console.log("Data migration response status:", dataRes.status); 205 + console.log("Data migration: Response status:", dataRes.status); 205 206 const dataText = await dataRes.text(); 206 - console.log("Data migration response:", dataText); 207 + console.log("Data migration: Raw response:", dataText); 207 208 208 209 if (!dataRes.ok) { 209 210 try { 210 211 const json = JSON.parse(dataText); 212 + console.error("Data migration: Error response:", json); 211 213 throw new Error(json.message || "Failed to migrate data"); 212 214 } catch { 215 + console.error("Data migration: Non-JSON error response:", dataText); 213 216 throw new Error(dataText || "Failed to migrate data"); 214 217 } 215 218 } 216 219 217 220 try { 218 221 const jsonData = JSON.parse(dataText); 222 + console.log("Data migration: Parsed response:", jsonData); 219 223 if (!jsonData.success) { 224 + console.error("Data migration: Unsuccessful response:", jsonData); 220 225 throw new Error(jsonData.message || "Data migration failed"); 221 226 } 222 - console.log("Data migration successful:", jsonData); 227 + console.log("Data migration: Success response:", jsonData); 223 228 } catch (e) { 224 - console.error("Failed to parse data migration response:", e); 229 + console.error("Data migration: Failed to parse response:", e); 225 230 throw new Error("Invalid response from server during data migration"); 226 231 } 227 232 233 + console.log("Data migration: Starting verification"); 228 234 updateStepStatus(1, "verifying"); 229 235 const verified = await verifyStep(1); 236 + console.log("Data migration: Verification result:", verified); 230 237 if (!verified) { 231 238 throw new Error("Data migration verification failed"); 232 239 } 233 240 } catch (error) { 241 + console.error("Data migration: Error caught:", error); 234 242 updateStepStatus( 235 243 1, 236 244 "error", ··· 467 475 468 476 // Helper to verify a step after completion 469 477 const verifyStep = async (stepNum: number) => { 478 + console.log(`Verification: Starting step ${stepNum + 1}`); 470 479 updateStepStatus(stepNum, "verifying"); 471 480 try { 481 + console.log(`Verification: Fetching status for step ${stepNum + 1}`); 472 482 const res = await fetch(`/api/migrate/status?step=${stepNum + 1}`); 483 + console.log(`Verification: Status response status:`, res.status); 473 484 const data = await res.json(); 485 + console.log(`Verification: Status data for step ${stepNum + 1}:`, data); 486 + 474 487 if (data.ready) { 488 + console.log(`Verification: Step ${stepNum + 1} is ready`); 475 489 updateStepStatus(stepNum, "completed"); 476 490 return true; 477 491 } else { 478 - updateStepStatus(stepNum, "error", data.reason || "Verification failed"); 492 + console.log(`Verification: Step ${stepNum + 1} is not ready:`, data.reason); 493 + const statusDetails = { 494 + activated: data.activated, 495 + validDid: data.validDid, 496 + repoCommit: data.repoCommit, 497 + repoRev: data.repoRev, 498 + repoBlocks: data.repoBlocks, 499 + expectedRecords: data.expectedRecords, 500 + indexedRecords: data.indexedRecords, 501 + privateStateValues: data.privateStateValues, 502 + expectedBlobs: data.expectedBlobs, 503 + importedBlobs: data.importedBlobs 504 + }; 505 + console.log(`Verification: Step ${stepNum + 1} status details:`, statusDetails); 506 + const errorMessage = `${data.reason || "Verification failed"}\nStatus details: ${JSON.stringify(statusDetails, null, 2)}`; 507 + updateStepStatus(stepNum, "error", errorMessage); 479 508 return false; 480 509 } 481 510 } catch (e) { 511 + console.error(`Verification: Error in step ${stepNum + 1}:`, e); 482 512 updateStepStatus(stepNum, "error", e instanceof Error ? e.message : String(e)); 483 513 return false; 484 514 }