From 7eea17064e9d11a167cdd78ceab2a9743b623e89 Mon Sep 17 00:00:00 2001 From: pvillaverde Date: Wed, 22 May 2024 17:03:06 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20exiting=20before=20publish?= =?UTF-8?q?ing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dev/pubsub.ts | 2 +- src/tasks/refreshBlogs.ts | 2 +- src/tasks/refreshPodcasts.ts | 2 +- src/tasks/refreshTwitchStreams.ts | 2 +- src/tasks/refreshYoutube.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dev/pubsub.ts b/src/dev/pubsub.ts index 94899ba..ccf2480 100644 --- a/src/dev/pubsub.ts +++ b/src/dev/pubsub.ts @@ -32,7 +32,7 @@ async function sendMessage() { const message = { id: id } - mqttService.publish("test", JSON.stringify(message), { qos: 2 }); + await mqttService.publishAsync("test", JSON.stringify(message), { qos: 2 }); /* logger.info(`Publishing to MQTT topic "test"`, JSON.stringify(message)); */ sendMessage(); } diff --git a/src/tasks/refreshBlogs.ts b/src/tasks/refreshBlogs.ts index 4ce1498..6559fe6 100644 --- a/src/tasks/refreshBlogs.ts +++ b/src/tasks/refreshBlogs.ts @@ -57,7 +57,7 @@ export default async function refreshBlogs() { entryLink: entry.link, }; logger.debug(`Publishing to MQTT topic "${mqttConfig.MQTT_TOPIC}"`, JSON.stringify(message)); - mqttService.publish(mqttConfig.MQTT_TOPIC, JSON.stringify(message), { qos: 2 }); + await mqttService.publishAsync(mqttConfig.MQTT_TOPIC, JSON.stringify(message), { qos: 2 }); } } logger.info(`${index + 1}/${blogs.length}`, `Recuperadas ${entries.length} entradas de ${item.title}.`); diff --git a/src/tasks/refreshPodcasts.ts b/src/tasks/refreshPodcasts.ts index 297d4a8..5aa7f4e 100644 --- a/src/tasks/refreshPodcasts.ts +++ b/src/tasks/refreshPodcasts.ts @@ -57,7 +57,7 @@ export default async function refreshPodcasts() { entryLink: entry.link, }; logger.debug(`Publishing to MQTT topic "${mqttConfig.MQTT_TOPIC}"`, JSON.stringify(message)); - mqttService.publish(mqttConfig.MQTT_TOPIC, JSON.stringify(message), { qos: 2 }); + await mqttService.publishAsync(mqttConfig.MQTT_TOPIC, JSON.stringify(message), { qos: 2 }); } } logger.info(`${index + 1}/${podcasts.length}`, `Recuperados ${entries.length} episodios de ${item.title}.`); diff --git a/src/tasks/refreshTwitchStreams.ts b/src/tasks/refreshTwitchStreams.ts index 33830b4..54bce86 100644 --- a/src/tasks/refreshTwitchStreams.ts +++ b/src/tasks/refreshTwitchStreams.ts @@ -43,7 +43,7 @@ export default async function refreshTwitchStreams() { channel: channel, game: game, }; - mqttService.publish(mqttConfig.MQTT_TOPIC, JSON.stringify(message), { qos: 2 }); + await mqttService.publishAsync(mqttConfig.MQTT_TOPIC, JSON.stringify(message), { qos: 2 }); } mqttService.end(); Deno.exit(0); diff --git a/src/tasks/refreshYoutube.ts b/src/tasks/refreshYoutube.ts index fb1d4c7..05908d1 100644 --- a/src/tasks/refreshYoutube.ts +++ b/src/tasks/refreshYoutube.ts @@ -61,7 +61,7 @@ export default async function refreshYoutube() { entryLink: entry.link, }; logger.debug(`Publishing to MQTT topic "${mqttConfig.MQTT_TOPIC}"`, JSON.stringify(message)); - mqttService.publish(mqttConfig.MQTT_TOPIC, JSON.stringify(message), { qos: 2 }); + await mqttService.publishAsync(mqttConfig.MQTT_TOPIC, JSON.stringify(message), { qos: 2 }); } } logger.info(