appsmithorg/appsmith · error · TriggerFailureError

Cannot find Iframe with name ${source} on this page

Error message

Cannot find Iframe with name ${source} on this page

What it means

TriggerFailureError thrown by executePostMessage when source is not 'window' and no iframe element with id `iframe-${source}` (or an iframe without a contentWindow) exists in the DOM. The saga uses getElementById, so a missing widget, a wrong id, or an iframe that hasn't attached its contentWindow yet all collapse to this single error.

Source

Thrown at app/client/src/sagas/ActionExecution/PostMessageSaga.ts:32

export function* executePostMessage(
  payload: TPostWindowMessageDescription["payload"],
) {
  const { message, source, targetOrigin } = payload;

  try {
    if (isEmpty(targetOrigin)) {
      throw new TriggerFailureError("Please enter a target origin URL.");
    } else {
      if (source !== "window") {
        const src = document.getElementById(
          `iframe-${source}`,
        ) as HTMLIFrameElement;

        if (src && src.contentWindow) {
          src.contentWindow.postMessage(message, targetOrigin);
        } else {
          throw new TriggerFailureError(
            `Cannot find Iframe with name ${source} on this page`,
          );
        }
      } else {
        window.parent.postMessage(message, targetOrigin, undefined);
      }
    }
  } catch (error) {
    yield call(showToastOnExecutionError, (error as Error).message);
  }
}

View on GitHub (pinned to 8cd9021c24)

Solutions

  1. Confirm an iframe widget with the exact name supplied in source is present on the current page.
  2. Set source to 'window' if the intent is to message the parent window, not an iframe.
  3. Delay the call (onPageLoad false, or via setTimeout in a JS object) until after the iframe's onSrcChangeReady event confirms it has loaded.

Example fix

// before: no iframe named 'foo' on page
postWindowMessage({ source: 'foo', targetOrigin: 'https://x.com', message: 'hi' });
// after: post to parent window instead
postWindowMessage({ source: 'window', targetOrigin: 'https://x.com', message: 'hi' });
Defensive patterns

Strategy: validation

Validate before calling

const iframe = document.getElementById(`iframe-${source}`);
if (source !== 'window' && (!iframe || !(iframe as HTMLIFrameElement).contentWindow)) {
  showAlert(`Iframe '${source}' is not available`, 'error');
  return;
}

Type guard

function iframeReady(name: string): boolean {
  const el = document.getElementById(`iframe-${name}`) as HTMLIFrameElement | null;
  return !!el && !!el.contentWindow;
}

Try / catch

try {
  postWindowMessage({ source, targetOrigin, message });
} catch (e) {
  if (e instanceof TriggerFailureError) showAlert(e.message, 'error');
}

Prevention

When it happens

Trigger: source references an iframe widget that is not rendered on the current page, is misspelled, or has been deleted; the iframe widget exists but is hidden/unmounted; the iframe loaded a sandboxed document that exposed no contentWindow.

Common situations: Typo in the source field; iframe widget sits on a different page/tab; the iframe's src is cross-origin and the inner document was swapped out; calling postWindowMessage during initial render before the iframe mounts.

Related errors


AI-assisted analysis of appsmithorg/appsmith@8cd9021c24 (2026-08-12). Data as JSON: /api/errors/c4fddf7bb1cfa171. Report an issue: GitHub.