{"record":{"id":"c65cbc36502ff9e4","repo":"twentyhq/twenty","slug":"updateprogressfunction-is-not-set","errorCode":null,"errorMessage":"updateProgressFunction is not set","messagePattern":"updateProgressFunction is not set","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-sdk/src/sdk/front-component/functions/updateProgress.ts","lineNumber":13,"sourceCode":"import { isDefined } from 'twenty-shared/utils';\n\nimport {\n  frontComponentHostCommunicationApi,\n  type UpdateProgressFunction,\n} from '../globals/frontComponentHostCommunicationApi';\n\nexport const updateProgress: UpdateProgressFunction = (progress) => {\n  const updateProgressFunction =\n    frontComponentHostCommunicationApi.updateProgress;\n\n  if (!isDefined(updateProgressFunction)) {\n    throw new Error('updateProgressFunction is not set');\n  }\n\n  return updateProgressFunction(progress);\n};\n","sourceCodeStart":1,"sourceCodeEnd":18,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-sdk/src/sdk/front-component/functions/updateProgress.ts#L1-L18","documentation":"Thrown by updateProgress when the host application has not registered an updateProgress function on the global frontComponentHostCommunicationApi. This function lets a front component report progress (a number value) to the Twenty host shell for progress-bar UI updates. If called outside the host context, the function is undefined.","triggerScenarios":"Calling updateProgress(progress) before the host has set frontComponentHostCommunicationApi.updateProgress. Happens in non-host environments, during testing without mocks, or when the host bridge is not yet initialized at call time.","commonSituations":"Unit testing a long-running front component that calls updateProgress without mocking the global API. Calling updateProgress during initial render before the host has wired up the bridge. Running the component in isolation (Storybook) where the host bridge doesn't exist.","solutions":["Only call updateProgress from event handlers or effects within a host-mounted front component.","In tests, mock the global: (globalThis as any).frontComponentHostCommunicationApi = { updateProgress: jest.fn().mockResolvedValue(undefined) }.","Ensure the host shell initializes frontComponentHostCommunicationApi.updateProgress before mounting front components.","Guard with an isDefined check to no-op when the function is unavailable."],"exampleFix":"// before\nimport { updateProgress } from 'twenty-sdk';\nfor (let i = 0; i <= 100; i += 10) {\n  await updateProgress(i);\n}\n\n// after — guard for non-host environments\nimport { frontComponentHostCommunicationApi } from 'twenty-sdk';\nfor (let i = 0; i <= 100; i += 10) {\n  if (frontComponentHostCommunicationApi.updateProgress) {\n    await frontComponentHostCommunicationApi.updateProgress(i);\n  }\n}","handlingStrategy":"type-guard","validationCode":"import { frontComponentHostCommunicationApi } from 'twenty-sdk';\nimport { isDefined } from 'twenty-shared/utils';\n\nconst canUpdateProgress = (): boolean => {\n  return isDefined(frontComponentHostCommunicationApi.updateProgress);\n};\n\nif (!canUpdateProgress()) {\n  console.debug('Progress reporting unavailable — skipping.');\n  return;\n}","typeGuard":"import { isDefined } from 'twenty-shared/utils';\nimport { frontComponentHostCommunicationApi } from 'twenty-sdk';\n\nconst isUpdateProgressAvailable = (): boolean => {\n  return isDefined(frontComponentHostCommunicationApi.updateProgress);\n};","tryCatchPattern":"try {\n  await updateProgress(progress);\n} catch (error) {\n  if (error instanceof Error && error.message === 'updateProgressFunction is not set') {\n    console.debug('Progress update not available outside host context.');\n    return;\n  }\n  throw error;\n}","preventionTips":["Only call updateProgress from event handlers or effects inside host-mounted components.","Mock frontComponentHostCommunicationApi.updateProgress in unit tests.","Guard progress calls with isDefined to degrade gracefully in non-host contexts."],"tags":["sdk","front-component","host-bridge","global-state"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}