Repository navigation
Replies: 12 comments
|
Confirmed against The exact-string comparison is duplicated across the codebase:
The consolidation opportunity is the real value here. Sites 2 and 3 carry
The one-line One caution on your fire-and-forget framing: you scoped this as "only the master / v0.1.3-alpha.1 line carries it, so the audience is small." That's accurate for the client exposure today, but sites 2/3/4 already ship in Given upstream external PRs aren't accepted at the moment, this is a solid reference-diff candidate — happy to help draft the 4-site patch + helper extraction if the maintainers open a path. |
|
Thanks for the detailed verification — all four sites check out on my side too, and I've folded them into one apply-clean reference diff below. Confirmed against
One nuance on the consolidation direction: site 4 cannot simply import the canonical helper. Reference diff (applies cleanly onto diff --git a/packages/code-runtime/code-runtime-worker-thread/src/worker-json.ts b/packages/code-runtime/code-runtime-worker-thread/src/worker-json.ts
index 40dcc2e1e8..52ab4a3079 100644
--- a/packages/code-runtime/code-runtime-worker-thread/src/worker-json.ts
+++ b/packages/code-runtime/code-runtime-worker-thread/src/worker-json.ts
@@ -87,7 +87,7 @@ function hasIntrinsicConstructor(prototype: object, name: 'Array' | 'Object'): b
try {
return constructor.name === name
&& constructor.prototype === prototype
- && intrinsicReflectApply(intrinsicFunctionToString, constructor, []) === `function ${name}() { [native code] }`
+ && String(intrinsicReflectApply(intrinsicFunctionToString, constructor, [])).replace(/\s+/gu, ' ') === `function ${name}() { [native code] }`
} catch {
return false
}
diff --git a/packages/core/tools/src/json-schema.ts b/packages/core/tools/src/json-schema.ts
index c064fb294c..f2d3e113a1 100644
--- a/packages/core/tools/src/json-schema.ts
+++ b/packages/core/tools/src/json-schema.ts
@@ -95,7 +95,7 @@ function hasIntrinsicConstructor(prototype: object, name: 'Array' | 'Object'): b
try {
return constructor.name === name
&& constructor.prototype === prototype
- && Function.prototype.toString.call(constructor) === `function ${name}() { [native code] }`
+ && Function.prototype.toString.call(constructor).replace(/\s+/gu, ' ') === `function ${name}() { [native code] }`
} catch {
return false
}
diff --git a/packages/extensions/cordis-host-runner/src/guard.ts b/packages/extensions/cordis-host-runner/src/guard.ts
index a70e47ef55..98264e10c8 100644
--- a/packages/extensions/cordis-host-runner/src/guard.ts
+++ b/packages/extensions/cordis-host-runner/src/guard.ts
@@ -47,7 +47,7 @@ function hasIntrinsicConstructor(prototype: object, name: 'Array' | 'Object'): b
try {
return constructor.name === name
&& constructor.prototype === prototype
- && Function.prototype.toString.call(constructor) === `function ${name}() { [native code] }`
+ && Function.prototype.toString.call(constructor).replace(/\s+/gu, ' ') === `function ${name}() { [native code] }`
} catch {
return false
}
diff --git a/packages/util/values/src/index.ts b/packages/util/values/src/index.ts
index 78a2cbb493..bf27288f74 100644
--- a/packages/util/values/src/index.ts
+++ b/packages/util/values/src/index.ts
@@ -22,7 +22,9 @@ function hasIntrinsicConstructor(prototype: object, name: 'Array' | 'Object'): b
try {
return constructor.name === name
&& constructor.prototype === prototype
- && Function.prototype.toString.call(constructor) === `function ${name}() { [native code] }`
+ // Engine-tolerant: Firefox formats native source across lines
+ // ("function Object() {\n [native code]\n}") while V8 keeps one line.
+ && Function.prototype.toString.call(constructor).replace(/\s+/gu, ' ') === `function ${name}() { [native code] }`
} catch {
return false
} |
|
Independent reproduction from a second environment (Windows 11 + Firefox, local build of dsh-v0.1.3-alpha.1). Same symptoms, same error chain, same root cause — I can confirm the exact-string comparison in hasIntrinsicConstructor fails on SpiderMonkey's multiline native-function formatting, which makes snapshotJsonValue reject every plain object. We also fixed and verified all four sites in one pass (util-values + the three latent host-side copies, including the captured-intrinsic variant in worker-json.ts with the String(...) wrapper). After a full rebuild, Firefox loads history, renders replies, and pages normally; Chromium shows no regression. The whitespace-normalization approach and the reference diff here match what we applied locally, which is a good sign. A Chinese-language write-up (marked as a duplicate of this thread) is at #5709 for anyone who prefers it. Thanks for the thorough report — hopefully the maintainers can land a fix (or open a PR path) before 0.1.3 ships to npm. I and Openclaw fixed this problem without noticing this thread and wasted 2 hours and 2$ on this shit. We should check Github first😭 |
|
Confirmed from source at All four sites are affected, as noted — Why whitespace normalization is safe (the check is a cross-realm heuristic, but worth stating precisely): One caveat on the proposed one-liner at the worker-thread site. Reference patch on my fork, with regression tests for both the SpiderMonkey rendering and the forged-constructor rejection (the existing Verified: the new tests fail on unpatched Same report in Chinese: #5709. |
|
Data point: macOS Safari (WebKit) and Firefox (Gecko) both affected — fix verified engine-agnostic Independent reproduction on macOS with a local v0.1.3-alpha.1 build:
Thanks for the detailed root-cause write-up — it matched my local patch verification exactly. |
|
Yes, I encountered the same issue while using it, and after investigation, I reached the same conclusion as you. |
|
谢谢你们把这条链查得这么透 —— 我们从 Firefox 侧也撞上了同一件事,并独立复现了你们的结论。这里补两样东西:一个可安装的落地形式,以及一处覆盖面说明。 Thanks for working this out so thoroughly — we hit the same thing from the Firefox side and reproduced your conclusions independently. Two additions: an installable form of the fix, and one coverage note. 我们的独立复现(真机 + 源码出处)/ Our independent reproduction (real device + sources)
English: On a real device under Gecko, 一个可安装的落地形式 / An installable form of the fix我们把这条链 —— 连同同一症状面上另外两条独立缺陷(Remote stream socket 的 waiter 没有超时兜底; We bundled this chain together with two other independent defects behind the same symptom (the Remote stream socket waiter has no timeout; three state-machine holes in 🔗 https://github.com/CNyaotian-Lunar/dsh-waitforsocket-timeout 它相对"参考 diff"的差别主要在工程性:幂等(重复跑安全)/ 自动备份 / 锚点不匹配即拒绝(exit 2)/ English: Compared with a reference diff, the difference is mostly engineering: idempotent (safe to re-run), auto-backup, refuses on anchor mismatch (exit 2), and auto-rolls-back when 覆盖面(与你们的 latent 判断一致)/ Coverage (agreeing with your "latent" reading)
English: ✅ Patched: the two client-side artifacts (the 一条上游建议 / One upstream suggestion与其"规范化空白",我们更建议把判据换成 English: Rather than whitespace normalization, we would suggest upstream switch the predicate to 本评论由 DSH agent 整理、经人工复核后提交 / Written by a DSH agent, reviewed by a human before posting. |
|
why hasnt been patched yet? many code changes and RC releases and this hasnt been fixed? |
EnglishThree things not yet covered here: 1. Scope on rc.2: only a response that is still streaming fails. The client validates raw chunks only for the active attempt ( 2. @CNyaotian-Lunar, please keep the 3. Test-backed fix on rc.2 (values site): Compare · Patch
中文补充三点本帖尚未涉及的内容: 1. rc.2 上的影响范围: 只有正在生成的回复会失败。客户端只校验当前 attempt 的原始 chunk( 2. @CNyaotian-Lunar,请保留 3. 基于 rc.2、带测试的修复(values 这一处): 对比 · 补丁
|
|
更正 + 致谢 / Correction and thanks @derSato 你第 2 点是对的,我们收回昨天那条建议 —— 抱歉,那是一条会降低安全性的建议。 错在哪:我们写的是「与其规范化空白,不如把判据换成 我们的实际做法(与你的修复同路):补丁改的是比较前规范化空白 —— 你第 1 点的范围澄清也与我们的实测一致:在 rc.2 上只有「正在生成中的回复」会失败 —— 我们那边的复现同样只在 English: @derSato your point 2 is right, and we withdraw yesterday's suggestion — sorry, it was advice that would have weakened the check. What went wrong: we wrote "instead of normalizing whitespace, switch the predicate to Our actual fix (and the one in our patch set) goes the same direction as yours: normalize whitespace before comparing ( Your point 1 (scope on rc.2) also matches our measurement: only a still-streaming response fails — in our reproduction the path is reachable only when 本评论由 DSH agent 整理、经人工复核后提交 / Written by a DSH agent, reviewed by a human before posting. |
补充:rc.2 官方 Worker 中,工具 Schema 的同类问题已实际触发补充一组 相关讨论:Safari/WebKit 会话渲染 #5919、Firefox 原生构造器检查 #8105。这里补充当前版本的工具路径执行证据,不把其他浏览器/平台的运行状态当作本轮已验证。 核验日期:2026-10-01。此处反馈原版工具校验在桌面 WebKit 中的兼容问题。 DSH 已有上游修复与遗漏官方提交 068c552(2026-09-21, 但 tools/src/json-schema.ts 仍将构造器文本与固定字符串比较: Function.prototype.toString.call(constructor) === `function ${name}() { [native code] }`;WebKit 返回的原生文本含换行,普通 最小复现与结果直接调用未修改的原版实现: isPlainJsonRecord({});
isPlainJsonArray([1, 2]);
parameterSchemaSpecToJsonSchema({});
assertSupportedJsonSchema({
type: 'object',
properties: { price: { type: 'number' } },
required: ['price'],
additionalProperties: false,
});macOS arm64,Node
缩减夹具共 12 项,Chrome 全部符合预期,WebKit 4 项合法输入不符合预期。兼容性失败时测试入口返回非零。另执行原版 缩减包直接使用四个原版源码文件。为排除整个 LLM 的 Node 入口,仅把 Schema 实际使用的 修复与回归建议建议上游核对已有提交的兼容方法,使工具 Schema 的原生构造器比较也适配引擎表示,同时保留构造器名称、原型归属、密集数组和不可见属性等校验。不建议无条件接受对象或使用宽松文本正则。 另有两处固定原生文本比较需要上游评估:
这两处仅完成源码检索,浏览器运行影响为 回归应覆盖同 realm/跨 realm 普通对象与数组、JSON 反序列化输入、嵌套 Schema、枚举和 可执行复现与验证边界以下提供可直接复制运行的缩减复现,直接读取四个原版源码文件并校验 SHA-256;不读取用户配置、模型 Key、会话或金融账户数据。这里只使用测试控制代码,不新增 Agent 循环、修改 Core 或改写 本结果来自桌面 Playwright WebKit,未在系统 Safari、iOS WKWebView 或 iPhone 真机复现,不把它表述为 iOS 已验证缺陷或所有 iOS 路线不可运行。 可执行的独立复现(原版源码 + esbuild + Playwright)在固定提交的 DSH 源码目录之外创建独立空目录,保存下面的 npm init -y
npm install --save-exact esbuild@0.28.1 playwright@1.61.1 --ignore-scripts --no-audit --no-fund需要本机已安装 Google Chrome。WebKit 请使用这个复现专用的新浏览器目录,避免安装器清理共享浏览器缓存: export PLAYWRIGHT_BROWSERS_PATH="$PWD/.isolated-browsers"
node node_modules/playwright/cli.js install webkit
node verify.mjs /path/to/deepseek-harness
import { build } from 'esbuild';
import { chromium, webkit } from 'playwright';
import { createServer } from 'node:http';
import { readFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import { createHash } from 'node:crypto';
if (!process.argv[2]) throw new Error('请提供固定提交的 DSH 源码目录');
const source = resolve(process.argv[2]);
// 固定本次复现的源码基线;不修改或补丁化原文件。
const hashes = {
"packages/core/tools/src/json-schema.ts": "13deffdfd34539e23706b0fde235991da45b2f07c5c18dbbf3ca734c1da0c788",
"packages/core/tools/src/schema.ts": "d54459d0ad535ff3375138d40f3b37b39c6994703f1ea6a331df9a97c7e3cd23",
"packages/llm/llm/src/error.ts": "63df8344d49df8f90054852c1de81bc6e56c11de11179e37dcad882be5758035",
"packages/util/values/src/index.ts": "1acc355c5eaffb81cd256f34a77f73e47242ace156f5287ab8313a92c45fe6a9"
};
for (const [name, expected] of Object.entries(hashes)) {
const bytes = await readFile(resolve(source, name));
if (createHash('sha256').update(bytes).digest('hex') !== expected) {
throw new Error('源码与复现基线不一致:' + name);
}
}
let fixtureSource = `import {
isPlainJsonRecord,
isPlainJsonArray,
assertSupportedJsonSchema,
} from "../../upstream/packages/core/tools/src/json-schema.ts";
import { parameterSchemaSpecToJsonSchema } from "../../upstream/packages/core/tools/src/schema.ts";
import { isJsonValue } from "../../upstream/packages/util/values/src/index.ts";
// 直接测试原版函数,不启动模型、插件树或任何金融业务。
const rows: {
name: string;
expected: boolean;
actual: boolean;
error?: string;
code?: string;
}[] = [];
function check(name: string, expected: boolean, action: () => boolean): void {
try {
rows.push({ name, expected, actual: action() });
} catch (error) {
const failure = error as Error & { code?: string };
rows.push({
name,
expected,
actual: false,
error: String(error),
code: failure.code,
});
}
}
check("普通对象", true, () => isPlainJsonRecord({}));
check("密集数组", true, () => isPlainJsonArray([1, 2]));
check("空参数映射编译", true, () => {
const schema = parameterSchemaSpecToJsonSchema({});
return (
schema.type === "object" &&
Object.keys(schema.properties ?? {}).length === 0
);
});
check("合法对象 Schema", true, () => {
assertSupportedJsonSchema({
type: "object",
properties: { price: { type: "number" } },
required: ["price"],
additionalProperties: false,
});
return true;
});
check("util-values 普通对象对照", true, () => isJsonValue({ price: 1 }));
check("util-values 密集数组对照", true, () => isJsonValue([1, 2]));
check("拒绝 Date", false, () => isPlainJsonRecord(new Date(0)));
check("拒绝 Map", false, () => isPlainJsonRecord(new Map()));
check("拒绝类实例", false, () => isPlainJsonRecord(new (class Entry {})()));
check("拒绝稀疏数组", false, () => isPlainJsonArray(new Array(2)));
check("拒绝带额外属性的数组", false, () =>
isPlainJsonArray(Object.assign([1], { label: "x" })),
);
check("拒绝伪造原型", false, () =>
isPlainJsonRecord(Object.create(Object.create(null))),
);
postMessage({
scope: "原版 Schema 函数的 Worker 最小复现,不是 Agent 或 iOS 验收",
status: rows.every((row) => row.actual === row.expected)
? "passed"
: "failed",
nativeObject: Function.prototype.toString.call(Object),
nativeArray: Function.prototype.toString.call(Array),
rows,
});
close();
`;
fixtureSource = fixtureSource.replace(/(["'])\.\.\/\.\.\/upstream\/([^"']+)\1/g,
(_whole, _quote, suffix) => JSON.stringify(resolve(source, suffix)));
const packed = await build({
stdin: { contents: fixtureSource, loader: 'ts', sourcefile: 'schema-worker.ts', resolveDir: process.cwd() },
bundle: true, write: false, platform: 'browser', format: 'iife', target: 'es2022',
treeShaking: true, tsconfigRaw: { compilerOptions: {} },
// 使用同一原版错误类和值工具,只隔离 LLM 的整个 Node 入口。
alias: {
'@deepseek-ai/dsh-llm': resolve(source, 'packages/llm/llm/src/error.ts'),
'@deepseek-ai/dsh-util-values': resolve(source, 'packages/util/values/src/index.ts'),
},
});
const html = '<!doctype html><meta charset="utf-8"><script>const w=new Worker("/worker.js");w.onmessage=e=>{globalThis.result=e.data;};w.onerror=e=>{globalThis.result={status:"failed",error:e.message};};</script>';
const server = createServer((request, response) => {
if (request.url === '/') {
response.writeHead(200, { 'Content-Type': 'text/html' }); response.end(html);
} else if (request.url === '/worker.js') {
response.writeHead(200, { 'Content-Type': 'text/javascript' }); response.end(packed.outputFiles[0].text);
} else { response.writeHead(404); response.end(); }
});
await new Promise(done => server.listen(0, '127.0.0.1', done));
const results = [];
try {
for (const name of ['chrome', 'webkit']) {
let browser;
try {
browser = await (name === 'chrome' ? chromium : webkit).launch(
name === 'chrome' ? { channel: 'chrome', headless: true } : { headless: true });
const page = await browser.newPage();
await page.goto('http://127.0.0.1:' + server.address().port);
await page.waitForFunction(() => globalThis.result !== undefined, null, { timeout: 20000 });
const result = await page.evaluate(() => globalThis.result);
results.push({ browser: name, version: browser.version(), result });
} catch (error) { results.push({ browser: name, error: String(error) }); }
finally { await browser?.close(); }
}
} finally { await new Promise(done => server.close(done)); }
console.log(JSON.stringify(results, null, 2));
if (results.some(row => row.result?.status !== 'passed')) process.exitCode = 1; |
|
补一个本贴还没被回答的事实性问题:哪个「发布版」第一次带上这个修复。 逐 tag 取
两点结论: 1. 修复在 master,但没有回移到 0.1.7 发布线。 2. 另一件没人提过的: 踩坑的人搜 "Firefox Loading history" 找不到任何官方线索——这大概就是这个 bug 在 #5677 / #5709 / #5757 被反复独立发现、还有人各自本地打补丁的原因。
如果 @baojiangtao 指出的 |
Uh oh!
There was an error while loading. Please reload this page.
Bug description
On the web UI, opening a session whose trajectory contains assistant raw chunk records
(any session after a normal agent turn) never finishes loading in Firefox-engine
browsers (Firefox, Zen). The history pane stays at "Loading history…" forever; the
client console logs a subscriber failure caused by the assistant-stream chunk validator:
The same server, the same session, and the same profile work fine in Chromium-family
browsers (Chrome, Brave, Edge). The Node-based TUI/SDK are unaffected.
Environment
master@d347e70390(thev0.1.3-alpha.1pre-release build); reproducedon a zero-plugin core-only profile as well, so plugins are not involved.
Chromium-family — fine.
unnoticed").
Steps to reproduce
master(d347e70390) or thev0.1.3-alpha.1build.stream data (i.e. any real session created by this build).
TypeErrorabove. Chromium on the same URL loads the same session normally.Root cause
packages/util/values/src/index.ts,hasIntrinsicConstructor()(lines 18–31), decideswhether a prototype is a realm-owned intrinsic by comparing the exact string form of
its constructor:
This assumes the V8 formatting of native functions, which is single-line. Firefox
formats natives across lines:
Measured live for this report (headless Firefox 1xx and Chromium, same machine):
The ECMAScript spec leaves the built-in (native) function string
implementation-defined — MDN explicitly warns its content "may be
implementation-defined" — so formatting is not guaranteed to match V8 on any
engine (MDN,
es-discuss).
SpiderMonkey's multiline output is confirmed above; Safari/WebKit was not
available for measurement, but the proposed fix is engine-agnostic (whitespace
normalization), so any engine that differs from V8 only in whitespace is covered
by the same change.
Consequently, on Firefox-engine browsers every plain object fails
isIntrinsicObjectPrototype(),snapshotJsonValue()returnsundefinedfor ordinaryJSON data, and the client-side assistant-stream validation (raw chunk records are
required to be lossless JSON) throws — so history rendering aborts before the first
message appears.
History: the exact-string comparison was consolidated into the new
dsh-util-valuespackage on 2026-08-30 (6c53fe6e2a,"refactor(values): make shared primitives duplicate-install safe"). It became
user-visible when the client-side chunk validator landed on 2026-09-02
(
f99b06eaed, "feat(session)!: embed assistant streams in format v2", 0.1.3 material).Why it went unnoticed so far
The affected client code has not shipped in any npm release yet. I checked the
published client bundles (
dsh-client-ui-trajectory,dsh-client-connection,dsh-api-session-controller,dsh-client-ui-chat) in0.1.2-alpha.5and0.1.2-rc.1(npmlatest): they contain neither the chunk validator nor theintrinsic check. Only the
masterline / the GitHub pre-releasev0.1.3-alpha.1(2026-09-04) carries it, so the affected audience is small. Once 0.1.3 reaches npm,
every Firefox-engine web-UI user will hit this. (Host-side copies of the same
pattern exist in
packages/core/tools/src/json-schema.ts,packages/extensions/ cordis-host-runner/src/guard.tsandpackages/code-runtime/.../src/worker-json.ts;they only run under Node/V8 today, so they are latent, not breaking.)
Suggested fix (one line)
Normalize whitespace before comparing; this makes Firefox behave exactly like V8 —
genuine FF-formatted natives now pass, and nothing is accepted that was not already
accepted under V8 formatting (the check is a duplicate-install/cross-realm heuristic,
not a security boundary; whitespace-collapsed lookalikes were already equal under V8):
Ready-to-apply patch (source only, applies cleanly onto
d347e70390; the fullpatch file is available on request) — inline below. Happy to open a PR through
whatever process you prefer (CONTRIBUTING.md says external PRs are not accepted
at the moment).
Verification performed
returns
"function Object() {\n [native code]\n}"— exact single-lineequality
false, equality after/\s+/gunormalizationtrue; Chromiumreturns the single-line form with exact equality
true.(MDN Function.prototype.toString);
engine formatting differences are a known es-discuss topic
(forward-incompatible Function.prototype.toString requirement).
masterserver: deterministic failure onsession open (attempt 0) with the quoted
TypeError; the same run under Chromiumrenders history cleanly.
same sessions normally; a full-snapshot validation that previously aborted now
passes.
it covers any engine whose native-string formatting differs from V8 in whitespace.
Discussion search (firefox, "Loading history", "lossless JSON", engine names)
return nothing matching this signature. Related-but-different threads:
#4513 /
#1550 /
#3408 (large or
corrupt sessions) and
#4919
(Firefox WebSocket mixed-content settings, unrelated).
中文摘要
Web UI 在 Firefox/Zen 等引擎上打开含 assistant 流数据的会话时永远停在
“Loading history…”。根因在
packages/util/values/src/index.ts的hasIntrinsicConstructor:它用Function.prototype.toString的精确字符串判断原生构造器,只适配了 V8 的单行格式;Firefox 会输出多行
(
function Object() {\n [native code]\n}),导致所有普通对象被判为非法,客户端 chunk 校验抛
TypeError: Assistant stream raw chunk must be a lossless JSON object。该代码 2026-08-30 引入 (6c53fe6e2a),2026-09-02 客户端校验(
f99b06eaed) 使其可见;目前只存在于 master / v0.1.3-alpha.1(npm 尚未发布),0.1.3 发布后所有 Firefox 引擎用户都会受影响。修复:比较前归一化空白
(
.replace(/\s+/gu, ' ')),使 Firefox 与 V8 行为一致。All reactions