{"record":{"id":"80f870aed2a462e2","repo":"tauri-apps/tauri","slug":"ipc-custom-protocol-failed-tauri-will-now-use-the","errorCode":null,"errorMessage":"IPC custom protocol failed, Tauri will now use the postMessage interface instead","messagePattern":"IPC custom protocol failed, Tauri will now use the postMessage interface instead","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tauri/scripts/ipc-protocol.js","lineNumber":60,"sourceCode":"        .then((response) => {\n          const callbackId =\n            response.headers.get('Tauri-Response') === 'ok' ? callback : error\n          // we need to split here because on Android the content-type gets duplicated\n          switch ((response.headers.get('content-type') || '').split(',')[0]) {\n            case 'application/json':\n              return response.json().then((r) => [callbackId, r])\n            case 'text/plain':\n              return response.text().then((r) => [callbackId, r])\n            default:\n              return response.arrayBuffer().then((r) => [callbackId, r])\n          }\n        })\n        .then(\n          ([callbackId, data]) => {\n            window.__TAURI_INTERNALS__.runCallback(callbackId, data)\n          },\n          (e) => {\n            console.warn(\n              'IPC custom protocol failed, Tauri will now use the postMessage interface instead',\n              e\n            )\n            // failed to use the custom protocol IPC (either the webview blocked a custom protocol or it was a CSP error)\n            // so we need to fallback to the postMessage interface\n            customProtocolIpcFailed = true\n            sendIpcMessage(message)\n          }\n        )\n    } else {\n      // otherwise use the postMessage interface\n      const { data } = processIpcMessage({\n        cmd,\n        callback,\n        error,\n        options: {\n          ...options,\n          customProtocolIpcBlocked: customProtocolIpcFailed","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri/scripts/ipc-protocol.js#L42-L78","documentation":"sendIpcMessage first attempts to deliver IPC messages through the webview's custom protocol (fetch-style). When that request rejects (webview blocks the custom scheme, CSP blocks the fetch, or the request errors), it logs this warning and permanently flips customProtocolIpcFailed so all subsequent IPC falls back to the postMessage interface.","triggerScenarios":"The custom-protocol IPC fetch fails: webview configuration disallows the tauri:// (or similar) scheme, a Content-Security-Policy connect-src directive blocks the request, or the protocol request itself errors.","commonSituations":"Strict CSP configured without allowing the Tauri IPC scheme in connect-src, custom webview builders that don't register the IPC custom protocol handler, or embedded webviews where the scheme is blocked by platform policy.","solutions":["Inspect the accompanying error `e` in the console to identify the blocking cause (CSP violation vs blocked scheme).","Update your CSP to allow the IPC origin, e.g. connect-src 'self' ipc: http://ipc.localhost tauri: in tauri.conf.json.","Ensure the webview/window is created through Tauri's builders so the custom protocol handler is registered.","If the fallback is acceptable, no action is needed — postMessage IPC still works, just with different performance characteristics."],"exampleFix":"// before: CSP blocking IPC\n\"csp\": \"default-src 'self'\"\n// after\n\"csp\": \"default-src 'self'; connect-src 'self' ipc: http://ipc.localhost tauri:\"","handlingStrategy":"fallback","validationCode":"const csp = window.__TAURI_INTERNALS__?.metadata?.currentCsp\nif (csp && !/connect-src[^;]*(ipc|tauri)/.test(csp)) console.warn('CSP may block custom protocol IPC')","typeGuard":null,"tryCatchPattern":"window.__TAURI_INTERNALS__.invoke('cmd')\n  .catch((e) => {\n    if (String(e).includes('custom protocol')) {\n      // library already falls back to postMessage; surface a config hint\n      console.warn('Enable ipc: http://ipc.localhost in CSP connect-src')\n    }\n  })","preventionTips":["Include ipc: and http://ipc.localhost in your CSP connect-src from day one.","Create webviews only through Tauri's window builders so the protocol handler is registered.","Check the console for this warning in CI/e2e runs to catch CSP regressions early."],"tags":["javascript","ipc","csp","custom-protocol","fallback"],"backgroundTag":"http-request-failed","analyzedSha":"460ec35447493200d64290dd7f015d5a91d0fd58","analyzedAt":"2026-09-18T23:55:51.277Z","contentChangedAt":"2026-09-18T23:55:51.277Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}