{"record":{"id":"42f77fdd6d97becc","repo":"appsmithorg/appsmith","slug":"found-a-promise-during-evaluation-data-fields-c","errorCode":null,"errorMessage":"Found a Promise() during evaluation. Data fields cannot execute asynchronous code.","messagePattern":"Found a Promise\\(\\) during evaluation\\. Data fields cannot execute asynchronous code\\.","errorType":"exception","errorClass":"FoundPromiseInSyncEvalError","httpStatus":null,"severity":"error","filePath":"app/client/src/workers/Evaluation/evaluate.ts","lineNumber":436,"sourceCode":"        isTriggerBased: isJSCollection,\n      });\n\n      Object.assign(EVAL_CONTEXT, dataTreeContext);\n    }\n\n    overrideEvalContext(EVAL_CONTEXT, context?.overrideContext);\n\n    Object.assign(self, EVAL_CONTEXT);\n\n    try {\n      result = indirectEval(script);\n\n      if (result instanceof Promise) {\n        /**\n         * If a promise is returned in data field then show the error to help understand data field doesn't await to resolve promise.\n         * NOTE: Awaiting for promise will make data field evaluation slower.\n         */\n        throw new FoundPromiseInSyncEvalError();\n      }\n      // TODO: Fix this the next time the file is edited\n      // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    } catch (error: any) {\n      const { errorCategory, errorMessage, rootcause } = errorModifier.run(\n        error,\n        { userScript: error.userScript || userScript, source: error.source },\n        [ActionInDataFieldErrorModifier, TypeErrorModifier],\n      );\n\n      errors.push({\n        errorMessage,\n        severity: Severity.ERROR,\n        raw: script,\n        errorType: PropertyEvaluationErrorType.PARSE,\n        originalBinding: userScript,\n        kind: {\n          category: errorCategory,","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/appsmithorg/appsmith/blob/8cd9021c24cdbea1c3c12c966073708e83db60c2/app/client/src/workers/Evaluation/evaluate.ts#L418-L454","documentation":"FoundPromiseInSyncEvalError thrown by the eval worker when a data-field binding returns a Promise. Data fields (Text.value, Input.defaultText, container background, etc.) are evaluated synchronously by indirectEval, so any returned Promise is unawaitable and would silently render [object Promise]. The error surfaces that the user must move the logic to an async context. The thrown error then routes through errorModifier.run alongside ActionInDataFieldErrorModifier and TypeErrorModifier.","triggerScenarios":"Binding a query directly: {{ getApi.run() }}; calling a JS object method that is async or returns a Promise; using fetch/await/Promise.then inside a data field; referencing a library function that returns a Promise.","commonSituations":"New users referencing the query function instead of its result; migrating from a JS object where async was fine into a data field; calling moment().then() or lodash debounce in a binding.","solutions":["Reference the query's cached result instead of calling it: {{ getApi.data }}.","Move async logic into a JS object function and trigger it via an event (onPageLoad, onClick), then bind to the JS object's result property.","Use the onSuccess callback of the action to refresh data the binding depends on.","Avoid fetch/Promise/await inside moustache bindings entirely."],"exampleFix":"// before — Text widget value\n{{ getApi.run() }}   // returns a Promise -> error\n// after\n{{ getApi.data }}    // resolved data, populated after run\n// or move to JS object\nexport default {\n  async load() { this.data = await getApi.run(); }\n};\n// bind widget to {{ JSObject.data }}","handlingStrategy":"type-guard","validationCode":"// Never call async code from a data field; route through a JS object\n// JS object\nexport default {\n  async load() { this.users = await getApi.run(); }\n};\n// widget binding uses {{ JSObject.users }}, not {{ getApi.run() }}","typeGuard":"function returnsPromise(v: unknown): v is Promise<unknown> {\n  return v != null && typeof (v as Promise<unknown>).then === 'function';\n}","tryCatchPattern":null,"preventionTips":["In data fields, bind to .data / .result properties of actions, never call them.","Move any await/fetch/Promise into a JS object triggered by events.","Treat the error message as authoritative: data fields are synchronous by design."],"tags":["evaluation","async","data-field","binding","worker"],"backgroundTag":null,"analyzedSha":"8cd9021c24cdbea1c3c12c966073708e83db60c2","analyzedAt":"2026-08-12T22:14:19.293Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}