Fixed the missing error message when logging invalid API key and improved the error message
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@trigger.dev/sdk": patch
|
||||
---
|
||||
|
||||
Fixed the missing error message when logging invalid API key and improved the error message
|
||||
@@ -350,7 +350,10 @@ export class TriggerServer {
|
||||
}
|
||||
);
|
||||
|
||||
this.#socket.close(4001, "Client not authenticated");
|
||||
this.#socket.close(
|
||||
4001,
|
||||
"Could not authenticate to the server because the API key is invalid"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
const logLevels = [
|
||||
"disabled",
|
||||
"log",
|
||||
"error",
|
||||
"log",
|
||||
"warn",
|
||||
"info",
|
||||
"debug",
|
||||
|
||||
@@ -16,6 +16,7 @@ import { Trigger, TriggerOptions } from "./trigger";
|
||||
import { TriggerContext, TriggerFetch } from "./types";
|
||||
import { generateErrorMessage, ErrorMessageOptions } from "zod-error";
|
||||
import terminalLink from "terminal-link";
|
||||
import chalk from "chalk";
|
||||
|
||||
const zodErrorMessageOptions: ErrorMessageOptions = {
|
||||
delimiter: {
|
||||
@@ -180,11 +181,11 @@ export class TriggerClient<TSchema extends z.ZodTypeAny> {
|
||||
return;
|
||||
}
|
||||
|
||||
this.#logger.error(`🚩 Could not connect to trigger.dev (code ${code})`);
|
||||
|
||||
if (reason) {
|
||||
this.#logger.error("Reason:", reason);
|
||||
}
|
||||
this.#logger.error(
|
||||
`${chalk.red("error")} Could not connect to trigger.dev${
|
||||
reason ? `: ${reason}` : `(code ${code})`
|
||||
}`
|
||||
);
|
||||
|
||||
// If #isConnected is already false, that means we are already trying to reconnect
|
||||
if (!this.#isConnected) return;
|
||||
@@ -741,6 +742,8 @@ export class TriggerClient<TSchema extends z.ZodTypeAny> {
|
||||
triggerTTL: this.#options.triggerTTL,
|
||||
});
|
||||
|
||||
console.log(response);
|
||||
|
||||
if (!response) {
|
||||
throw new Error("Could not initialize workflow with server");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user