From f409e9f3297c976ef797b91623f21db24bb4d021 Mon Sep 17 00:00:00 2001 From: Matt Aitken Date: Sun, 2 Jul 2023 18:54:25 +0100 Subject: [PATCH] =?UTF-8?q?Improved=20the=20messaging=20when=20it=E2=80=99?= =?UTF-8?q?s=20connecting=20with=20a=20retry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cli/src/commands/dev.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/commands/dev.ts b/packages/cli/src/commands/dev.ts index 2ac432a1e..c8649d3e0 100644 --- a/packages/cli/src/commands/dev.ts +++ b/packages/cli/src/commands/dev.ts @@ -81,6 +81,14 @@ export async function devCommand(path: string, anyOptions: any) { ); } else { attemptCount++; + + if (attemptCount === 5) { + logger.info(`🔌 Still connecting to Trigger.dev...`); + } else if (attemptCount === 10) { + logger.error(`🚨 Failed to connect: ${result.error}`); + logger.info(`🔌 Retrying...`); + } + const delay = backoff(attemptCount); // console.log(`Attempt: ${attemptCount}`, delay); await wait(delay); @@ -181,14 +189,16 @@ async function refreshEndpoint( }); if (!response.ok) { - logger.error(`🚨 Endpoint couldn't refresh: ${response.error}`); - return { success: false as const }; + return { success: false as const, error: response.error }; } return { success: true as const, data: response.data }; } catch (e) { - logger.error(`🚨 Endpoint couldn't refresh: ${e}`); - return { success: false as const }; + if (e instanceof Error) { + return { success: false as const, error: e.message }; + } else { + return { success: false as const, error: "Unknown error" }; + } } }