Fix cache initialization and add better error handling
- Initialize g.cache early to prevent undefined access errors - Add detailed error handling for metadata.json parsing - Prevent cascade failures when ZIP deployment fails - Add JSON content preview for debugging parsing issues 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
c13e1118ca
commit
0a39249851
|
|
@ -89,7 +89,7 @@ export const deploy = {
|
||||||
throw new Error(`No deployment file found for timestamp: ${ts}`);
|
throw new Error(`No deployment file found for timestamp: ${ts}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g.deploy.content) {
|
// Initialize cache early to prevent undefined access errors
|
||||||
console.log(`[DEBUG] Setting up cache and compression...`);
|
console.log(`[DEBUG] Setting up cache and compression...`);
|
||||||
g.cache = {
|
g.cache = {
|
||||||
br: {},
|
br: {},
|
||||||
|
|
@ -100,6 +100,8 @@ export const deploy = {
|
||||||
timeout: null,
|
timeout: null,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (g.deploy.content) {
|
||||||
startBrCompress();
|
startBrCompress();
|
||||||
console.log(`[DEBUG] Compression started`);
|
console.log(`[DEBUG] Compression started`);
|
||||||
|
|
||||||
|
|
@ -273,7 +275,16 @@ export const deploy = {
|
||||||
if (entry.filename === 'metadata.json') {
|
if (entry.filename === 'metadata.json') {
|
||||||
console.log(`[DEBUG] Found metadata.json, parsing content...`);
|
console.log(`[DEBUG] Found metadata.json, parsing content...`);
|
||||||
const metadataStr = new TextDecoder().decode(fileContent);
|
const metadataStr = new TextDecoder().decode(fileContent);
|
||||||
const metadata = JSON.parse(metadataStr);
|
let metadata;
|
||||||
|
|
||||||
|
try {
|
||||||
|
metadata = JSON.parse(metadataStr);
|
||||||
|
console.log(`[DEBUG] Successfully parsed metadata.json`);
|
||||||
|
} catch (jsonError) {
|
||||||
|
console.error(`[ERROR] Failed to parse metadata.json: ${jsonError.message}`);
|
||||||
|
console.error(`[ERROR] JSON content preview:`, metadataStr.substring(0, 200));
|
||||||
|
throw new Error(`Invalid JSON in metadata.json: ${jsonError.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
console.log(`[DEBUG] Parsed metadata:`, {
|
console.log(`[DEBUG] Parsed metadata:`, {
|
||||||
layouts: metadata.layouts?.length || 0,
|
layouts: metadata.layouts?.length || 0,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue