{"record":{"id":"c1707b19329759cf","repo":"jlcodes99/cockpit-tools","slug":"externalimport","errorCode":null,"errorMessage":"[ExternalImport] 读取待处理导入请求失败:","messagePattern":"\\[ExternalImport\\] 读取待处理导入请求失败:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/App.tsx","lineNumber":3569,"sourceCode":"        unlisten();\n      }\n    };\n  }, [handleExternalProviderImportRawPayload]);\n\n  useEffect(() => {\n    let canceled = false;\n    void invoke<unknown>('external_import_take_pending')\n      .then((payload) => {\n        if (canceled) return;\n        if (!payload) {\n          console.info('[ExternalImport][App] 启动时无待处理导入 payload');\n          return;\n        }\n        console.info('[ExternalImport][App] 启动时读取到待处理导入 payload');\n        void handleExternalProviderImportRawPayload(payload);\n      })\n      .catch((error) => {\n        console.warn('[ExternalImport] 读取待处理导入请求失败:', error);\n      });\n    return () => {\n      canceled = true;\n    };\n  }, [handleExternalProviderImportRawPayload]);\n\n  // 窗口拖拽处理\n  const handleDragStart = (event: ReactMouseEvent<HTMLDivElement>) => {\n    if (event.button !== 0) {\n      return;\n    }\n    void getCurrentWindow().startDragging().catch((error) => {\n      console.warn('[Window] startDragging failed:', error);\n    });\n  };\n\n  useEffect(() => {\n    const handleRequestNavigate = (e: Event) => {","sourceCodeStart":3551,"sourceCodeEnd":3587,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src/App.tsx#L3551-L3587","documentation":"On startup MainApp reads any pending external import request payload from the backend; the promise has a .catch that logs this warning and gives up. It means a queued external-provider import (e.g. from a deep link or another window) could not be read and is silently dropped — the user's intended import never happens.","triggerScenarios":"The startup read rejects: backend command/IPC failure, the pending-request store/file is corrupt or locked, permission error reading the payload, or the reader was invoked after cancellation with a stale handle.","commonSituations":"App crash left a partially written pending-import file; Tauri command renamed after an update so invoke fails; race where cleanup (`canceled = true`) closes before the read resolves on fast unmounts.","solutions":["Read the logged error: 'command not found' means a frontend/backend API mismatch; IO errors point at the pending-payload store","Validate/handle a corrupt pending payload by deleting it and informing the user instead of failing silently","Ensure the read happens after the backend is ready (await app readiness before the effect's invoke)","Preserve the payload (don't clear it) on read failure so a retry on next launch can recover the import"],"exampleFix":"// before\n.catch((error) => {\n  console.warn('[ExternalImport] 读取待处理导入请求失败:', error);\n});\n// after\n.catch((error) => {\n  console.warn('[ExternalImport] 读取待处理导入请求失败:', error);\n  notifyUserImportPendingButUnread(); // keep payload for retry on next launch\n});","handlingStrategy":"fallback","validationCode":"async function readPendingImportSafely(): Promise<RawImportPayload | null> {\n  try {\n    return await readPendingImportPayload();\n  } catch (error) {\n    console.warn('[ExternalImport] 读取待处理导入请求失败:', error);\n    return null;\n  }\n}","typeGuard":"function isRawImportPayload(v: unknown): v is RawImportPayload {\n  return isPlainObject(v) && typeof (v as { kind?: unknown }).kind === 'string';\n}","tryCatchPattern":"readPendingImportPayload()\n  .then((payload) => handleExternalProviderImportRawPayload(payload))\n  .catch((error) => {\n    console.warn('[ExternalImport] 读取待处理导入请求失败:', error);\n    // keep the pending payload so the import can be retried on next launch\n  });","preventionTips":["Don't delete the pending payload unless the read AND import succeed","Wait for backend readiness before reading pending requests","Handle corrupt payloads by quarantining them with a user notice","Share command names between frontend and backend to avoid invoke mismatches"],"tags":["ipc","external-import","startup"],"backgroundTag":"ipc-command-failed","analyzedSha":"1ed8b77992d62ca81fabf744deb0839ad361d5bf","analyzedAt":"2026-09-05T09:51:41.178Z","contentChangedAt":"2026-09-05T09:51:41.178Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}