Stable Diffusion: fix stack overflow logging comfy workflows with large images The base64-redaction regex added to the workflow debug log blew V8's stack (RangeError: Maximum call stack size exceeded) once a real multi-megabyte reference image was substituted in, killing every ComfyUI generation client-side before the request was sent. Log the workflow before image payloads are substituted instead - same privacy benefit, no regex over huge strings.

9ea95c8f60cc1ff6db60a41e720498c617382e12

permissionBRICK <40219477+permissionBRICK@users.noreply.github.com>

1 files changed, +7 -4Ignore whitespace
public/scripts/extensions/stable-diffusion/index.js+7 -4
@@ -5227,6 +5227,13 @@ async function generateComfyImageCommon(prompt, negativePrompt, signal, basePath
52275227 (extension_settings.sd.comfy_placeholders ?? []).forEach(ph => {
52285228 workflow = workflow.replaceAll(`"%${ph.find}%"`, JSON.stringify(substituteParams(ph.replace)));
52295229 });
5230+ // Log the workflow before image payloads are substituted in: keeps private
5231+ // image data (avatars, reference images) out of the console and avoids
5232+ // scanning multi-megabyte strings (a redaction regex here previously blew
5233+ // the stack on large reference images).
5234+ console.log(`{
5235+ "prompt": ${workflow}
5236+ }`);
52305237 if (/%user_avatar%/gi.test(workflow)) {
52315238 const response = await fetch(getUserAvatarUrl());
52325239 if (response.ok) {
@@ -5261,10 +5268,6 @@ async function generateComfyImageCommon(prompt, negativePrompt, signal, basePath
52615268 workflow = workflow.replaceAll('"%reference_image%"', JSON.stringify(refBase64));
52625269 workflow = workflow.replaceAll('"%reference-image%"', JSON.stringify(refBase64));
52635270 }
5264- // Log the workflow with base64 image payloads redacted (avatars/reference images are private).
5265- console.log(`{
5266- "prompt": ${workflow.replace(/"[A-Za-z0-9+/=]{200,}"/g, '"<base64 image redacted>"')}
5267- }`);
52685271 const promptResult = await fetch(`${basePath}/generate`, {
52695272 method: 'POST',
52705273 headers: getRequestHeaders(),