Skip to content

fix(effect-runtime): surface bounded underlying handler error for local operability - #9434

Open
alaleiwang wants to merge 1 commit into
loopx-project:mainfrom
alaleiwang:feat/qualified-node-sqlite
Open

alaleiwang wants to merge 1 commit into
loopx-project:mainfrom
alaleiwang:feat/qualified-node-sqlite

Conversation

@alaleiwang

Copy link
Copy Markdown

Problem

When a managed effect-runtime handler fails, the fallback returns a fixed message:

{"ok":false,"error":"Effect runtime handler failed unexpectedly"}

The underlying error (the actual cause) is discarded, and the Python layer intentionally
does not surface the Node stack. This makes failures nearly impossible to diagnose.

Real-world example that motivated this

On Windows with Node v24.9.0 (bundled SQLite 3.50.4), loopx bootstrap failed with the
generic message above. The true cause was only visible after adding temporary logging:

SQLite authority runtime is not qualified (SQLite 3.50.4); require the WAL-reset fix
in SQLite 3.51.3+/3.50.7+/3.44.6+

i.e. an unqualified embedded SQLite became an opaque "handler failed unexpectedly".

Change

In loopx/control_plane/effect_runtime_errors.ts final fallback, include a bounded
underlying error message (no stack, truncated) via the existing boundedMessage:

return {
  kind: "internal_failure",
  code: "unexpected_handler_error",
  message: boundedMessage(
    `Effect runtime handler failed unexpectedly: ${(error as any)?.message || String(error)}`,
    "Effect runtime handler failed unexpectedly",
  ),
};

Scope / risk

  • Only the error message of the last-resort handler changes; no control-flow change.
  • Message is bounded/truncated; no stack is exposed.

Verification

  • Before: generic "Effect runtime handler failed unexpectedly".
  • After: same failure now includes the underlying cause (e.g. the SQLite qualification error).

Notes

Consider also surfacing the specific "Node SQLite must be >=3.50.7" hint directly when the
embedded SQLite version check fails, instead of the generic handler error.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

动机 / Motivation

受影响的是遇到 Node SQLite 版本不合格的 bootstrap 用户,以及接收 Effect runtime typed failure 的 Python 和 CLI 调用方。分叉基线以固定文本序列化 unexpected_handler_error。Node SQLite 资格拒绝可因此丢掉有用的低版本诊断。 同一真实 Effect exchange 使用合成 handler 缓冲返回,比较普通 Error 与无字符串转换的异常值。另跑标准 Node 分类和 Python 持久 journal 错误回读。 当前 fallback 在格式化任意异常时自身抛出 TypeError,exchange 未产出原 request ID 的 typed response。既有 Node 分类测试及 Python 真 socket journal 回读也各新增一项失败。 已验证本地 macOS 的 Node 24.21.0、实际 Python ↔ Node socket 及 synthetic handler exchange。作者的 Windows 和旧内嵌 SQLite bootstrap 组合仍待验证。托管 CI 未查询。

改动思路 / Approach

sqlite_runtime 持有可支持的内嵌 SQLite 版本与关闭语义。effectRuntimeErrorPayload 持有通用失败编码,exchange 持有请求关联和 wire envelope。 保留通用 error taxonomy,限制增强诊断的 activation 在具体 SQLite 资格分支。 在已知的 SQLite runtime 资格失败出口返回稳定、可修复的诊断,通过现有 typed envelope 传递。通用 fallback 继续保证能编码未知异常。 采用在实际调用入口核验结果的做法。作者的 PR 说明给出 SQLite 版本定位目标,现有基线测试定义回退契约。

具体改动 / Changes

精确 head 8d76cdb35d75448806be272425894f3b63847a2a,目标分支快照和共同祖先均为 b34f0e6157968251dedbd88552ccad34c4fdeef9。生产改动仅一个 TypeScript 文件。按行尾归一后是替换一个 fallback message 表达式,实际提交 +140 / −137 来自全文件 LF 变为 CRLF 并加入该表达式。

关键代码讲解

  • boundedMessage。压为单行并把字串限制在 240 字符。 源码

  • effectRuntimeErrorPayload。分派显式协议错误、系统 I/O 与未知 handler 失败。 源码

  • exchangeEffectRuntimeRequest。捕获真实 handler 异常,绑定 request ID 并编码。 源码

  • SQLite runtime qualification。已知 SQLite 运行时拒绝及其修复说明的 owner。 源码

  • 已有 wire boundary 单测固定通用回退语义。 基线测试

对主干的风险 / Risks

[P2] 未知异常可使错误响应编码自身抛错

未知异常携带无法安全转为字符串的值,通用 handler 已进入 error serializer。 当前 fallback 在格式化任意异常时自身抛出 TypeError,exchange 未产出原 request ID 的 typed response。既有 Node 分类测试及 Python 真 socket journal 回读也各新增一项失败。 在 SQLite 资格 owner 构造可公开的稳定诊断,保留通用的不可抛出 fallback。恢复 committed 差异的原 LF 行结尾,并复跑两个回归入口。 对应源码

变化对默认调用生效。调用路径从读取 runtime 回执到 scheduler CLI 共用同一错误编码,超出 Windows bootstrap 的故障范围。缩短显示文本仍无法保证字符串转换成功,也无法替代已知故障的 typed diagnostics。固定通用兜底加专门资格诊断保留 distinct error kind、request ID 和现有读回。 普通 Error 在当前头仍编码内部错误,消息有一行和 240 字符上限。普通请求拒绝与已知 filesystem 分类的对照继续通过。

语义与本地验证

Node 分类测试基线 3/3,当前头 2/3。Python 真 socket 测试基线 2/2,当前头 1/2。定向 exchange 在本轮新增一个无 typed wire frame 的反例。标准本地 premerge 的 10 个计划检查通过,committed diff check 因 CRLF 失败。 已验证本地 macOS 的 Node 24.21.0、实际 Python ↔ Node socket 及 synthetic handler exchange。作者的 Windows 和旧内嵌 SQLite bootstrap 组合仍待验证。托管 CI 未查询。

我的整体评价 / Verdict

REQUEST_CHANGES。 在 SQLite 资格 owner 构造可公开的稳定诊断,保留通用的不可抛出 fallback。恢复 committed 差异的原 LF 行结尾,并复跑两个回归入口。

English verdict: REQUEST_CHANGES. Surface a typed SQLite qualification diagnostic while preserving a total generic error fallback.

kind: "internal_failure",
code: "unexpected_handler_error",
message: boundedMessage(
`Effect runtime handler failed unexpectedly: ${(error as any)?.message || String(error)}`,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 未知异常携带无法安全转为字符串的值,通用 handler 已进入 error serializer。 当前 fallback 在格式化任意异常时自身抛出 TypeError,exchange 未产出原 request ID 的 typed response。既有 Node 分类测试及 Python 真 socket journal 回读也各新增一项失败。 在 SQLite 资格 owner 构造可公开的稳定诊断,保留通用的不可抛出 fallback。恢复 committed 差异的原 LF 行结尾,并复跑两个回归入口。

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants