From bae4de942c414f3d356adcc26ba0fe54f9cdcc37 Mon Sep 17 00:00:00 2001 From: Martijn Date: Thu, 19 Oct 2023 14:55:36 +0200 Subject: [PATCH 1/3] fix(picqer): dont disable webhook --- .../src/api/picqer.controller.ts | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/packages/vendure-plugin-picqer/src/api/picqer.controller.ts b/packages/vendure-plugin-picqer/src/api/picqer.controller.ts index c990902b..9f000283 100644 --- a/packages/vendure-plugin-picqer/src/api/picqer.controller.ts +++ b/packages/vendure-plugin-picqer/src/api/picqer.controller.ts @@ -22,11 +22,27 @@ export class PicqerController { ); // Middleware isn't loaded when using the test server from @vendure/testing, so we use the normal body const rawBody = (req as any).rawBody || JSON.stringify(body); - await this.picqerService.handleHook({ - body, - channelToken, - rawBody, - signature, - }); + try { + await this.picqerService.handleHook({ + body, + channelToken, + rawBody, + signature, + }); + } catch (e: any) { + Logger.error( + `Error handling incoming hook '${body.event}': ${e.message}`, + loggerCtx + ); + + // FIXME: For now, don't throw insufficient stock error, to prevent webhook disabling + if ( + e.message !== + 'INSUFFICIENT_STOCK_ON_HAND_ERROR: INSUFFICIENT_STOCK_ON_HAND_ERROR' + ) { + return; + } + throw e; + } } } From c5f8d4ad5c05624fef0fc06d83dd1f58f22b648a Mon Sep 17 00:00:00 2001 From: Martijn Date: Thu, 19 Oct 2023 14:56:07 +0200 Subject: [PATCH 2/3] fix(picqer): dont disable webhook --- packages/vendure-plugin-picqer/src/api/picqer.controller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vendure-plugin-picqer/src/api/picqer.controller.ts b/packages/vendure-plugin-picqer/src/api/picqer.controller.ts index 9f000283..27fae6df 100644 --- a/packages/vendure-plugin-picqer/src/api/picqer.controller.ts +++ b/packages/vendure-plugin-picqer/src/api/picqer.controller.ts @@ -37,7 +37,7 @@ export class PicqerController { // FIXME: For now, don't throw insufficient stock error, to prevent webhook disabling if ( - e.message !== + e.message === 'INSUFFICIENT_STOCK_ON_HAND_ERROR: INSUFFICIENT_STOCK_ON_HAND_ERROR' ) { return; From 271792c1477e9cac4abb3ede019276b9625ac8ea Mon Sep 17 00:00:00 2001 From: Martijn Date: Thu, 19 Oct 2023 14:58:49 +0200 Subject: [PATCH 3/3] fix(picqer): changelog and version bump --- packages/vendure-plugin-picqer/CHANGELOG.md | 4 ++++ packages/vendure-plugin-picqer/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/vendure-plugin-picqer/CHANGELOG.md b/packages/vendure-plugin-picqer/CHANGELOG.md index 3e2a803a..32a0b231 100644 --- a/packages/vendure-plugin-picqer/CHANGELOG.md +++ b/packages/vendure-plugin-picqer/CHANGELOG.md @@ -1,3 +1,7 @@ +# 1.0.11 + +- Don't throw insufficient stock errors on incoming webhooks, because it will eventually disable the entire webhook in Picqer + # 1.0.10 - Send streetline1 + streetline2 as address in Picqer diff --git a/packages/vendure-plugin-picqer/package.json b/packages/vendure-plugin-picqer/package.json index 03a65727..40f4f27f 100644 --- a/packages/vendure-plugin-picqer/package.json +++ b/packages/vendure-plugin-picqer/package.json @@ -1,6 +1,6 @@ { "name": "@pinelab/vendure-plugin-picqer", - "version": "1.0.10", + "version": "1.0.11", "description": "Vendure plugin syncing to orders and stock with Picqer", "author": "Martijn van de Brug ", "homepage": "https://pinelab-plugins.com/",