From 0e50d32ec5155cbf2b72d10b9b0357b9ddbca956 Mon Sep 17 00:00:00 2001 From: Zain Nadeem Date: Wed, 24 Jun 2026 21:39:01 +0500 Subject: [PATCH] Fix stale presenter after expected operation errors (#2589) Co-authored-by: GCHQDeveloper581 <63102987+GCHQDeveloper581@users.noreply.github.com> (tweaked tests) --- src/core/Recipe.mjs | 2 ++ tests/operations/tests/RenderPDF.mjs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/core/Recipe.mjs b/src/core/Recipe.mjs index 0886e994..0a2e217d 100755 --- a/src/core/Recipe.mjs +++ b/src/core/Recipe.mjs @@ -241,9 +241,11 @@ class Recipe { // Cannot rely on `err instanceof OperationError` here as extending // native types is not fully supported yet. dish.set(err.message, "string"); + this.lastRunOp = null; return i; } else if (err instanceof DishError || err?.type === "DishError") { dish.set(err.message, "string"); + this.lastRunOp = null; return i; } else { const e = typeof err == "string" ? { message: err } : err; diff --git a/tests/operations/tests/RenderPDF.mjs b/tests/operations/tests/RenderPDF.mjs index f359aa20..ff9c3e5a 100644 --- a/tests/operations/tests/RenderPDF.mjs +++ b/tests/operations/tests/RenderPDF.mjs @@ -7,6 +7,9 @@ import TestRegister from "../../lib/TestRegister.mjs"; +const oversizedPdfLikeInput = "%PDF-1.0\n" + "A".repeat(5000); + + TestRegister.addTests([ { name: "RenderPDF", @@ -34,4 +37,19 @@ TestRegister.addTests([ } ], }, + { + name: "RenderPDF followed by Generate QR Code error returns plain text", + input: oversizedPdfLikeInput, + expectedOutput: "Error generating QR code. (Error: Too much data)", + recipeConfig: [ + { + "op": "Render PDF", + "args": ["Raw"] + }, + { + "op": "Generate QR Code", + "args": ["PNG", 1, 0, "High"] + } + ], + }, ]);