Skip to content

[Bug]: Linux 打包版自动获取密钥时 keyService 未初始化 #976

Description

@TMYTiMidlY

提交前确认

  • 我已搜索过现有的 Issues,确认这不是重复问题
  • 我使用的是最新版本
  • 我已阅读过相关文档

使用平台

Linux

问题严重程度

核心功能受影响(在下一个常规发布中必须修复)

问题描述

Linux 打包版中,首次初始化后点击自动获取数据库密钥或图片密钥时,主进程 IPC handler 报错,keyServiceundefined,导致 Linux 自动获取密钥流程不可用。

复现步骤

  1. 使用 upstream/main 构建 Linux 产物。
  2. 安装 release/linux-unpacked
    cd release/linux-unpacked
    sudo ./install.sh
  3. 清空 WeFlow 用户数据目录后重新启动:
    trash-put ~/.config/weflow
    weflow
  4. 进入初始化流程,点击自动获取微信密钥或图片密钥。
  5. 控制台出现 keyServiceundefined 的错误。

预期行为

Linux 下自动获取数据库密钥、图片密钥时,KeyServiceLinux 应该已完成初始化,并正常执行对应方法。

实际行为

控制台报错:

APPIMAGE env is not defined, current application is not an AppImage
Error occurred in handler for 'key:autoGetDbKey': TypeError: Cannot read properties of undefined (reading 'autoGetDbKey')
    at /opt/weflow/resources/app.asar/dist-electron/main.js:799:51565
    at Session.<anonymous> (node:electron/js2c/browser_init:2:116478)
    at Session.emit (node:events:508:28)

Error occurred in handler for 'key:autoGetImageKey': TypeError: Cannot read properties of undefined (reading 'autoGetImageKey')
    at /opt/weflow/resources/app.asar/dist-electron/main.js:799:51703
    at Session.<anonymous> (node:electron/js2c/browser_init:2:116478)
    at Session.emit (node:events:508:28)

其中 APPIMAGE env is not defined 是非 AppImage 安装方式下的 updater 提示,不是本 issue 的修复目标;真正阻断功能的是后续 keyServiceundefined

另外在打包产物中也观察到过 Linux key service 加载阶段错误:

TypeError [ERR_INVALID_ARG_VALUE]: The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received undefined
    at createRequire (...)
    at /opt/weflow/resources/app.asar/dist-electron/keyServiceLinux-*.js

操作系统版本

Ubuntu 24.04.4 LTS / WSL2

应用版本

4.3.0 / upstream main ca6c479

系统架构

x64

补充信息

本地验证过一个最小修复:

  1. electron/main.ts 中 Linux 分支同步初始化 KeyServiceLinux
  2. electron/services/keyServiceLinux.ts 中使用 createRequire(__filename),避免打包后的 CommonJS 产物里 import.meta.url 被转换成无效值。

修复版重新完整构建并安装后,Linux 初始化和图片解密流程验证通过。

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions