Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry async calls if they fail #814

Merged
merged 30 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
96527cb
Adding new event for log rocket to track when supabase calls failed
travjenkins Nov 2, 2023
72e6786
More import fixes
travjenkins Nov 2, 2023
19315f7
Adding a warning for when the network is down according to the browser
travjenkins Nov 2, 2023
54b8176
Updating to latest notistack
travjenkins Nov 2, 2023
c7b8c9c
Being safe
travjenkins Nov 3, 2023
6b16a7d
Reverting the table caching display
travjenkins Nov 3, 2023
8087947
Making errors display with more insight for users
travjenkins Nov 3, 2023
cb4c620
Making errors display with more insight for users : new file
travjenkins Nov 3, 2023
3f34ce7
Switching over to the retry library
travjenkins Nov 7, 2023
3e230b2
Getting more functions over to retrying
travjenkins Nov 7, 2023
8f2afdd
Fixing how a response is handled
travjenkins Nov 7, 2023
b4e7704
Comments and instruction clean up
travjenkins Nov 9, 2023
4d544c3
Merge branch 'main' into travjenkins/retryAsyncFailures
travjenkins Nov 9, 2023
1307ecb
post merge fix
travjenkins Nov 9, 2023
90da169
Cleaning up typing for invoke
travjenkins Nov 9, 2023
cf50548
clean up
travjenkins Nov 9, 2023
9205ca8
handling combined grants
travjenkins Nov 9, 2023
ff6e565
Getting connectos to retry
travjenkins Nov 9, 2023
b6629a5
Getting directives using retry
travjenkins Nov 9, 2023
7c299b9
Getting drafts using retry
travjenkins Nov 9, 2023
5d6749c
marking todo
travjenkins Nov 9, 2023
62c177e
Getting hydration using retry
travjenkins Nov 9, 2023
ad7dda1
Getting inferred schema using retry
travjenkins Nov 9, 2023
3825b36
Do not want to throw on error to help with retry
travjenkins Nov 9, 2023
791d5d2
marking todo
travjenkins Nov 9, 2023
13239b1
Do not want to throw on error to help with retry
travjenkins Nov 9, 2023
3529240
getting live specs using retry
travjenkins Nov 9, 2023
4b72b34
Getting pub view using retry
travjenkins Nov 9, 2023
43ffa10
Getting more stuff working with retry
travjenkins Nov 9, 2023
efbc6a0
PR: updating name
travjenkins Nov 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 71 additions & 52 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"madge": "^5.0.2",
"material-ui-popup-state": "^5.0.9",
"monaco-editor": "^0.34.1",
"notistack": "^2.0.8",
"notistack": "^3.0.1",
"p-limit": "^4.0.0",
"path-list-to-tree": "^1.1.1",
"pretty-bytes": "^6.1.0",
Expand All @@ -89,6 +89,7 @@
"react-virtualized-auto-sizer": "^1.0.20",
"react-window": "^1.8.9",
"readable-numbers": "^1.0.7",
"retry": "^0.13.1",
"safe-stable-stringify": "^2.4.3",
"serve": "^14.2.0",
"stripe": "^12.1.1",
Expand All @@ -111,6 +112,7 @@
"@types/react-gtm-module": "^2.0.1",
"@types/react-lazylog": "^4.5.1",
"@types/react-window": "^1.8.5",
"@types/retry": "^0.12.5",
"compress-create-react-app": "^1.4.1",
"eslint-config-kentcdodds": "^20.3.1",
"eslint-plugin-jest-dom": "^4.0.3",
Expand Down
14 changes: 9 additions & 5 deletions src/api/combinedGrantsExt.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { PostgrestResponse } from '@supabase/postgrest-js';
import {
defaultTableFilter,
RPCS,
SortingProps,
supabaseClient,
supabaseRetry,
TABLES,
} from 'services/supabase';
import { AuthRoles } from 'types';
Expand Down Expand Up @@ -76,11 +78,13 @@ const getGrants_Users = (
};

export const getAuthRoles = async (capability: string) => {
return supabaseClient
.rpc<AuthRoles>(RPCS.AUTH_ROLES, {
min_capability: capability,
})
.throwOnError();
return supabaseRetry<PostgrestResponse<AuthRoles>>(
() =>
supabaseClient.rpc<AuthRoles>(RPCS.AUTH_ROLES, {
min_capability: capability,
}),
'getAuthRoles'
);
};

export { getGrants, getGrants_Users };
16 changes: 10 additions & 6 deletions src/api/connectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
handleSuccess,
SortingProps,
supabaseClient,
supabaseRetry,
TABLES,
} from 'services/supabase';

Expand Down Expand Up @@ -59,12 +60,15 @@ const DETAILS_FORM_QUERY = `
`;

const getConnectors_detailsForm = async (connectorId: string) => {
const data = await supabaseClient
.from(TABLES.CONNECTORS)
.select(DETAILS_FORM_QUERY)
.eq('id', connectorId)
.eq('connector_tags.connector_id', connectorId)
.then(handleSuccess<ConnectorsQuery_DetailsForm[]>, handleFailure);
const data = await supabaseRetry(
() =>
supabaseClient
.from(TABLES.CONNECTORS)
.select(DETAILS_FORM_QUERY)
.eq('id', connectorId)
.eq('connector_tags.connector_id', connectorId),
'getConnectors_detailsForm'
).then(handleSuccess<ConnectorsQuery_DetailsForm[]>, handleFailure);

return data;
};
Expand Down
37 changes: 23 additions & 14 deletions src/api/directives.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PostgrestSingleResponse } from '@supabase/postgrest-js';
import { DIRECTIVES } from 'directives/shared';
import { UserClaims } from 'directives/types';
import {
Expand All @@ -9,6 +10,7 @@ import {
RPCS,
SortingProps,
supabaseClient,
supabaseRetry,
TABLES,
updateSupabase,
} from 'services/supabase';
Expand Down Expand Up @@ -56,12 +58,15 @@ const callUpdate = (
};

const exchangeBearerToken = async (token: string) => {
return supabaseClient
.rpc<ExchangeResponse>(RPCS.EXCHANGE_DIRECTIVES, {
bearer_token: token,
})
.throwOnError()
.single();
return supabaseRetry<PostgrestSingleResponse<ExchangeResponse>>(
() =>
supabaseClient
.rpc(RPCS.EXCHANGE_DIRECTIVES, {
bearer_token: token,
})
.single(),
'exchangeBearerToken'
);
};

const submitDirective = async (
Expand Down Expand Up @@ -146,18 +151,22 @@ const generateGrantDirective = (
};

const getDirectiveByToken = async (token: string) => {
const data = await supabaseClient
.from(TABLES.DIRECTIVES)
.select(`spec,token`)
.eq('token', token)
.then(
handleSuccess<Pick<GrantDirective, 'spec' | 'token'>[]>,
handleFailure
);
const data = await supabaseRetry(
() =>
supabaseClient
.from(TABLES.DIRECTIVES)
.select(`spec,token`)
.eq('token', token),
'getDirectiveByToken'
).then(
handleSuccess<Pick<GrantDirective, 'spec' | 'token'>[]>,
handleFailure
);

return data;
};

// Used in table hydrator which handles the retrying
const getDirectivesByType = (
directiveType: keyof typeof DIRECTIVES,
pagination: any,
Expand Down
Loading