Skip to content

Commit cb243bb

Browse files
Merge pull request #1004 from appwrite/fix-race-condition-invalidation
fix: functions variable creation race condition invalidation
2 parents 36df725 + 4d88ef4 commit cb243bb

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,17 @@
2424
2525
const sdkCreateVariable = async (key: string, value: string) => {
2626
await sdk.forProject.functions.createVariable($func.$id, key, value);
27-
await invalidate(Dependencies.VARIABLES);
28-
await invalidate(Dependencies.FUNCTION);
27+
await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.FUNCTION)]);
2928
};
3029
3130
const sdkUpdateVariable = async (variableId: string, key: string, value: string) => {
3231
await sdk.forProject.functions.updateVariable($func.$id, variableId, key, value);
33-
await invalidate(Dependencies.VARIABLES);
34-
await invalidate(Dependencies.FUNCTION);
32+
await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.FUNCTION)]);
3533
};
3634
3735
const sdkDeleteVariable = async (variableId: string) => {
3836
await sdk.forProject.functions.deleteVariable($func.$id, variableId);
39-
await invalidate(Dependencies.VARIABLES);
40-
await invalidate(Dependencies.FUNCTION);
37+
await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.FUNCTION)]);
4138
};
4239
</script>
4340

src/routes/console/project-[project]/updateVariables.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,11 @@
138138
selectedVar = null;
139139
showPromoteModal = false;
140140
141-
await invalidate(Dependencies.FUNCTION);
142-
await invalidate(Dependencies.VARIABLES);
143-
await invalidate(Dependencies.PROJECT_VARIABLES);
141+
await Promise.all([
142+
invalidate(Dependencies.FUNCTION),
143+
invalidate(Dependencies.VARIABLES),
144+
invalidate(Dependencies.PROJECT_VARIABLES)
145+
]);
144146
145147
addNotification({
146148
type: 'success',

0 commit comments

Comments
 (0)