From 3b36cefbcaef5cb0a702f977bafa1ffcda687dde Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Mon, 21 Jun 2021 18:17:08 -0700 Subject: [PATCH] Fix UDP conn request promise rejection warning --- lib/api-functions.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/api-functions.ts b/lib/api-functions.ts index 200eb66..e98e2dc 100644 --- a/lib/api-functions.ts +++ b/lib/api-functions.ts @@ -145,7 +145,7 @@ export async function connectionRequest( const debug = !!getConfig(snapshot, "cwmp.debug", {}, now, evalCallback); - let udpProm: Promise; + let udpProm = Promise.resolve(false); if (udpConnectionRequestAddress) { try { const u = new URL("udp://" + udpConnectionRequestAddress); @@ -156,6 +156,9 @@ export async function connectionRequest( UDP_CONNECTION_REQUEST_PORT, debug, deviceId + ).then( + () => true, + () => false ); } catch (err) { // Ignore invalid address @@ -171,14 +174,7 @@ export async function connectionRequest( deviceId ); - if (udpProm) { - try { - await udpProm; - return ""; - } catch (err) { - // Ignore - } - } + if (await udpProm) return ""; return status; }