From a84add364a322cd6a767ff7b5fabd663e0780bad Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Wed, 20 Dec 2023 13:23:34 +0530 Subject: [PATCH] :art: Added logs, and improved debugging --- Taskfile.yaml | 15 ++++++------ .../helpers/execute-query-with-context.ts | 24 +++++++++++++++---- src/apps/auth/root.tsx | 2 ++ 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index 8a433ada4..b0fb795b8 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -8,8 +8,9 @@ tasks: interactive: true cmds: - | - BASE_URL=dev.kloudlite.io + BASE_URL=devc.kloudlite.io COOKIE_DOMAIN=".kloudlite.io" + GATEWAY_URL="http://gateway.karthik-testing.svc.cluster.local" case {{.app}} in "auth") PORT=4000 @@ -38,7 +39,7 @@ tasks: ;; "vision") - URL_SUFFIX="-vision" + URL_SUFFIX="" ;; *) @@ -47,18 +48,18 @@ tasks: esac - REMIX_DEV_ORIGIN="https://{{.app}}$URL_SUFFIX.dev.kloudlite.io" + REMIX_DEV_ORIGIN="https://{{.app}}$URL_SUFFIX.devc.kloudlite.io" cp -r ./static/common/. ./public/ cp -r ./static/{{.app}}/. ./public/ case "{{.tscheck}}" in "no") - URL_SUFFIX=$URL_SUFFIX APP={{.app}} PORT=$PORT BASE_URL=$BASE_URL REMIX_DEV_ORIGIN=$REMIX_DEV_ORIGIN DEVELOPER=$(whoami) pnpm dev + GATEWAY_URL=$GATEWAY_URL URL_SUFFIX=$URL_SUFFIX APP={{.app}} PORT=$PORT BASE_URL=$BASE_URL REMIX_DEV_ORIGIN=$REMIX_DEV_ORIGIN DEVELOPER=$(whoami) pnpm dev ;; *) - URL_SUFFIX=$URL_SUFFIX APP={{.app}} PORT=$PORT BASE_URL=$BASE_URL REMIX_DEV_ORIGIN=$REMIX_DEV_ORIGIN DEVELOPER=$(whoami) pnpm dev & pnpm typecheck + GATEWAY_URL=$GATEWAY_URL URL_SUFFIX=$URL_SUFFIX APP={{.app}} PORT=$PORT BASE_URL=$BASE_URL REMIX_DEV_ORIGIN=$REMIX_DEV_ORIGIN DEVELOPER=$(whoami) pnpm dev & pnpm typecheck ;; esac @@ -121,12 +122,12 @@ tasks: case $(whoami) in "bikash") - BASE_URL=dev.kloudlite.io + BASE_URL=devc.kloudlite.io URL_SUFFIX=1 ;; "vision") - BASE_URL=dev.kloudlite.io + BASE_URL=devc.kloudlite.io URL_SUFFIX="-vision" ;; diff --git a/lib/server/helpers/execute-query-with-context.ts b/lib/server/helpers/execute-query-with-context.ts index 13366d9e0..40e9c6edc 100644 --- a/lib/server/helpers/execute-query-with-context.ts +++ b/lib/server/helpers/execute-query-with-context.ts @@ -79,11 +79,25 @@ export const ExecuteQueryWithContext = ( query: print(q), variables: variables || {}, }, + timeout: 5000, }); - let { data,errors } = resp.data; - if(errors){ - throw new Error(JSON.stringify(errors)) + let { data } = resp.data; + const { errors } = resp.data; + + if (errors) { + const e = errors as Error[]; + if (e.length === 1) { + throw errors[0]; + } + + throw new Error( + e.reduce((acc, curr) => { + return `${acc}\n\n1. ${curr.name ? `${curr.name}:` : ''}:${ + curr.message + }${curr.stack ? `\n${curr.stack}` : ''}`; + }, 'Errors:') + ); } if (data) { @@ -97,11 +111,13 @@ export const ExecuteQueryWithContext = ( } return { ...resp.data, data }; } catch (err) { - console.error('ErrorIn:', apiName, err); if ((err as AxiosError).response) { + console.error('ErrorIn:', apiName, (err as Error).name); return (err as AxiosError).response?.data; } + console.error('ErrorIn:', apiName, (err as Error).message); + return { errors: [ { diff --git a/src/apps/auth/root.tsx b/src/apps/auth/root.tsx index e4c66c7bb..0bfd12fd5 100644 --- a/src/apps/auth/root.tsx +++ b/src/apps/auth/root.tsx @@ -9,6 +9,8 @@ export const links = () => { return [...baseLinks(), { rel: 'stylesheet', href: authStylesUrl }]; }; +export { ErrorBoundary } from '~/lib/app-setup/root'; + const Layout = ({ children }: ChildrenProps) => { return ( //