diff --git a/packages/nodes-base/nodes/Bannerbear/Bannerbear.node.ts b/packages/nodes-base/nodes/Bannerbear/Bannerbear.node.ts
index d5e6f44fd5f..ea1ac20289a 100644
--- a/packages/nodes-base/nodes/Bannerbear/Bannerbear.node.ts
+++ b/packages/nodes-base/nodes/Bannerbear/Bannerbear.node.ts
@@ -148,23 +148,22 @@ export class Bannerbear implements INodeType {
}
responseData = await bannerbearApiRequest.call(this, 'POST', '/images', body);
if (additionalFields.waitForImage && responseData.status !== 'completed') {
- let maxIntents = 2;
+ let maxTries = (additionalFields.waitForImageMaxTries as number) || 3;
+
const promise = (uid: string) => {
let data: IDataObject = {};
return new Promise((resolve, reject) => {
const timeout = setInterval(async () => {
- if (!maxIntents) {
- clearInterval(timeout);
- reject(new Error('Image did not finish procesing after 2 intents'));
- }
-
data = await bannerbearApiRequest.call(this, 'GET', `/images/${uid}`);
if (data.status === 'completed') {
clearInterval(timeout);
resolve(data);
}
- maxIntents--;
+ if (--maxTries === 0) {
+ clearInterval(timeout);
+ reject(new Error('Image did not finish processing after multiple tries.'));
+ }
}, 2000);
});
};
diff --git a/packages/nodes-base/nodes/Bannerbear/ImageDescription.ts b/packages/nodes-base/nodes/Bannerbear/ImageDescription.ts
index 00cc1f64444..223368d924b 100644
--- a/packages/nodes-base/nodes/Bannerbear/ImageDescription.ts
+++ b/packages/nodes-base/nodes/Bannerbear/ImageDescription.ts
@@ -81,6 +81,33 @@ export const imageFields = [
default: '',
description: 'Metadata that you need to store e.g. ID of a record in your DB',
},
+ {
+ displayName: 'Wait for Image',
+ name: 'waitForImage',
+ type: 'boolean',
+ default: false,
+ description: `Wait for the image to be proccesed before returning.
+ If after three tries the images is not ready, an error will be thrown.
+ Number of tries can be increased by setting "Wait Max Tries".`,
+ },
+ {
+ displayName: 'Wait Max Tries',
+ name: 'waitForImageMaxTries',
+ type: 'number',
+ typeOptions: {
+ minValue: 1,
+ maxValue: 10,
+ },
+ displayOptions: {
+ show: {
+ waitForImage: [
+ true,
+ ],
+ },
+ },
+ default: 3,
+ description: `How often it should check if the image is available before it fails.`,
+ },
{
displayName: 'Webhook URL',
name: 'webhookUrl',
@@ -88,14 +115,6 @@ export const imageFields = [
default: '',
description: 'A url to POST the Image object to upon rendering completed',
},
- {
- displayName: 'Wait for Image',
- name: 'waitForImage',
- type: 'boolean',
- default: false,
- description: `Wait for the image to be proccesed before returning.
- If after two tries the images is not ready an error will be thrown`,
- },
],
},
{