fix: add try-catch protection for Trianglify canvas generation to prevent runtime errors in Docker

This commit is contained in:
Muhammad Ibrahim
2025-10-28 18:25:13 +00:00
parent eb0218bdcb
commit ac420901a6
2 changed files with 46 additions and 36 deletions

View File

@@ -240,6 +240,7 @@ const Layout = ({ children }) => {
// Generate Trianglify background for dark mode
useEffect(() => {
const generateBackground = () => {
try {
if (
bgCanvasRef.current &&
themeConfig?.login &&
@@ -263,6 +264,10 @@ const Layout = ({ children }) => {
// Render to canvas
pattern.toCanvas(bgCanvasRef.current);
}
} catch (error) {
// Canvas/trianglify not available, skip background generation
console.warn("Could not generate Trianglify background:", error);
}
};
generateBackground();

View File

@@ -60,6 +60,7 @@ const Login = () => {
// Generate Trianglify background based on selected theme
useEffect(() => {
const generateBackground = () => {
try {
if (canvasRef.current && themeConfig?.login) {
// Get current date as seed for daily variation
const today = new Date();
@@ -79,6 +80,10 @@ const Login = () => {
// Render to canvas
pattern.toCanvas(canvasRef.current);
}
} catch (error) {
// Canvas/trianglify not available, skip background generation
console.warn("Could not generate Trianglify background:", error);
}
};
generateBackground();