diff --git a/src/server/types/AppearanceLayer.js b/src/server/types/AppearanceLayer.js index ee4ab29..94de066 100644 --- a/src/server/types/AppearanceLayer.js +++ b/src/server/types/AppearanceLayer.js @@ -357,7 +357,16 @@ function convertLayerTypeToSwfAssetType(layerType) { * image for this layer, it could be a supporting sprite for the JS library!) */ async function loadAndCacheAssetDataFromManifest(db, layer) { - let manifest = layer.manifest && JSON.parse(layer.manifest); + let manifest; + try { + manifest = layer.manifest && JSON.parse(layer.manifest); + } catch (e) { + console.error( + `Layer ${layer.id} has invalid manifest JSON: ` + + `${JSON.stringify(layer.manifest)}` + ); + manifest = null; + } // When the manifest is specifically null, that means we don't know if // it exists yet. Load it to find out! @@ -430,6 +439,14 @@ async function loadAndCacheAssetManifest(db, layer) { // reload all the missing ones at that time. const manifestJson = manifest ? JSON.stringify(manifest) : ""; + if (manifestJson.length > 16777215) { + console.warn( + `Skipping saving asset manifest for layer ${layer.id}, because its ` + + `length is ${manifestJson.length}, which exceeds the database limit.` + ); + return manifest; + } + const [ result, ] = await db.execute(