playov2-js-utilities 0.3.41 → 0.3.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -77,6 +77,9 @@ async function createHttpTask(queueId, payload, messageProcessingProperties, tas
|
|
|
77
77
|
LOGGER.info(requestId, { name: response.name, response }, `Added task to queue ${queueId}}`);
|
|
78
78
|
return response;
|
|
79
79
|
} catch (err) {
|
|
80
|
+
if (err && err.code === 6) { // Idempotent request - assume sucess when the task being tried to save is already there!
|
|
81
|
+
return Promise.resolve('success!');
|
|
82
|
+
}
|
|
80
83
|
throw err;
|
|
81
84
|
}
|
|
82
85
|
};
|
|
@@ -115,6 +118,15 @@ const deleteHttpTask = async (queueId, taskId) => {
|
|
|
115
118
|
try {
|
|
116
119
|
await cloudtasks.projects.locations.queues.tasks.delete(requestData);
|
|
117
120
|
} catch (err) {
|
|
121
|
+
/*
|
|
122
|
+
Error response schema -
|
|
123
|
+
Naturally if GCP response is that task didn't exist while we were trying to delete it, then we should not
|
|
124
|
+
pass back the error to calle function and resume operations as normal. As delete operation is atomic and idempotent.
|
|
125
|
+
*/
|
|
126
|
+
if (err.response.data && err.response.data.error && err.response.data.error.message === 'Requested entity was not found.') {
|
|
127
|
+
return Promise.resolve('success!');
|
|
128
|
+
}
|
|
129
|
+
|
|
118
130
|
throw err;
|
|
119
131
|
}
|
|
120
132
|
};
|