From 8bd7b3235f979fb0ee064e5e883dcff8d01272e4 Mon Sep 17 00:00:00 2001 From: Marco polo Date: Thu, 21 Nov 2024 16:14:02 -0500 Subject: [PATCH] [oss] Don't retry mutations (#26085) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary & Motivation as titled. ## How I Tested These Changes hardcoded mutations to return an error and saw us hit this codepath Screenshot 2024-11-21 at 3 40 28 PM > Insert changelog entry or delete this section. [ui] In OSS, mutations are no longer retried. --- js_modules/dagster-ui/packages/app-oss/src/App.tsx | 1 + .../dagster-ui/packages/ui-core/src/app/AppProvider.tsx | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/js_modules/dagster-ui/packages/app-oss/src/App.tsx b/js_modules/dagster-ui/packages/app-oss/src/App.tsx index 0cc69568319b9..aa3558db1b682 100644 --- a/js_modules/dagster-ui/packages/app-oss/src/App.tsx +++ b/js_modules/dagster-ui/packages/app-oss/src/App.tsx @@ -33,6 +33,7 @@ const config = { origin: process.env.NEXT_PUBLIC_BACKEND_ORIGIN || document.location.origin, telemetryEnabled, statusPolling: new Set(['code-locations', 'daemons']), + idempotentMutations: false, }; const appCache = createAppCache(); diff --git a/js_modules/dagster-ui/packages/ui-core/src/app/AppProvider.tsx b/js_modules/dagster-ui/packages/ui-core/src/app/AppProvider.tsx index 1e7bd9f6e9708..f92823501710b 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/app/AppProvider.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/app/AppProvider.tsx @@ -1,6 +1,6 @@ import {RetryLink} from '@apollo/client/link/retry'; import {WebSocketLink} from '@apollo/client/link/ws'; -import {getMainDefinition} from '@apollo/client/utilities'; +import {getMainDefinition, isMutationOperation} from '@apollo/client/utilities'; import {CustomTooltipProvider} from '@dagster-io/ui-components'; import * as React from 'react'; import {useContext} from 'react'; @@ -67,6 +67,7 @@ export interface AppProviderProps { origin: string; telemetryEnabled?: boolean; statusPolling: Set; + idempotentMutations?: boolean; }; // Used for localStorage/IndexedDB caching to be isolated between instances/deployments @@ -82,6 +83,7 @@ export const AppProvider = (props: AppProviderProps) => { origin, telemetryEnabled = false, statusPolling, + idempotentMutations = true, } = config; // todo dish: Change `deleteExisting` to true soon. (Current: 1.4.5) @@ -112,7 +114,10 @@ export const AppProvider = (props: AppProviderProps) => { return new RetryLink({ attempts: { max: 3, - retryIf: async (error, _operation) => { + retryIf: async (error, operation) => { + if (!idempotentMutations && isMutationOperation(operation.query)) { + return false; + } if (error && error.statusCode && httpStatusCodesToRetry.has(error.statusCode)) { return true; }