From e2b6fa4d3d8b3c794f6669d46fa4f75117111194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Fri, 10 Jan 2025 10:34:05 +0100 Subject: [PATCH] refactor(core): Patch Bull to include stack trace on job fail (#12547) --- package.json | 1 + patches/bull@4.12.1.patch | 21 +++++++++++++++++++++ pnpm-lock.yaml | 7 +++++-- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 patches/bull@4.12.1.patch diff --git a/package.json b/package.json index 76e8199d4e..1a4929dade 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,7 @@ }, "patchedDependencies": { "typedi@0.10.0": "patches/typedi@0.10.0.patch", + "bull@4.12.1": "patches/bull@4.12.1.patch", "pkce-challenge@3.0.0": "patches/pkce-challenge@3.0.0.patch", "pyodide@0.23.4": "patches/pyodide@0.23.4.patch", "@types/express-serve-static-core@4.17.43": "patches/@types__express-serve-static-core@4.17.43.patch", diff --git a/patches/bull@4.12.1.patch b/patches/bull@4.12.1.patch new file mode 100644 index 0000000000..2c68a33865 --- /dev/null +++ b/patches/bull@4.12.1.patch @@ -0,0 +1,21 @@ +diff --git a/lib/job.js b/lib/job.js +index 6a3606974fd3e397c6c5b2b6e65b20670c68f753..4cdbed1d564ceeb5a80c92eb605e49cfd3c8ccdd 100644 +--- a/lib/job.js ++++ b/lib/job.js +@@ -511,9 +511,14 @@ Job.prototype.finished = async function() { + } + }; + +- const onFailed = (jobId, failedReason) => { ++ const onFailed = async (jobId, failedReason) => { + if (String(jobId) === String(this.id)) { +- reject(new Error(failedReason)); ++ const job = await Job.fromId(this.queue, this.id); ++ const error = new Error(failedReason); ++ if (job && job.stacktrace && job.stacktrace.length > 0) { ++ error.stack = job.stacktrace.join('\n'); ++ } ++ reject(error); + removeListeners(); + } + }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f121c953fe..0ff203359e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -124,6 +124,9 @@ patchedDependencies: '@types/ws@8.5.4': hash: nbzuqaoyqbrfwipijj5qriqqju path: patches/@types__ws@8.5.4.patch + bull@4.12.1: + hash: ep6h4rqtpclldfcdohxlgcb3aq + path: patches/bull@4.12.1.patch pkce-challenge@3.0.0: hash: dypouzb3lve7vncq25i5fuanki path: patches/pkce-challenge@3.0.0.patch @@ -804,7 +807,7 @@ importers: version: 2.4.3 bull: specifier: 4.12.1 - version: 4.12.1 + version: 4.12.1(patch_hash=ep6h4rqtpclldfcdohxlgcb3aq) cache-manager: specifier: 5.2.3 version: 5.2.3 @@ -17822,7 +17825,7 @@ snapshots: - supports-color optional: true - bull@4.12.1: + bull@4.12.1(patch_hash=ep6h4rqtpclldfcdohxlgcb3aq): dependencies: cron-parser: 4.9.0 get-port: 5.1.1