dsh-session-ops 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/admin.js +9 -3
- package/lib/types/admin.d.ts +4 -0
- package/package.json +1 -1
package/lib/admin.js
CHANGED
|
@@ -604,12 +604,18 @@ export async function sessionHealth(sessionId, source, holds) {
|
|
|
604
604
|
resident: residentOf(holds, id),
|
|
605
605
|
running: runningOf(holds, id),
|
|
606
606
|
};
|
|
607
|
-
|
|
608
|
-
|
|
607
|
+
// 必须**在接收者上**调用:内核 JSONL 后端的 `stat` 是原型方法,方法体第一句读
|
|
608
|
+
// `this.ensureRootEncoding()`(还有 `this.tracker` / `this.findLog`)。摘成游离函数
|
|
609
|
+
// 再 `stat(id)` 会以 `this === undefined` 调用,抛
|
|
610
|
+
// `Cannot read properties of undefined (reading 'ensureRootEncoding')`——
|
|
611
|
+
// 0.2.4 的「会话日志」section 就是这么整块报「读取失败」的。
|
|
612
|
+
const persistence = source.persistence;
|
|
613
|
+
if (typeof persistence?.stat !== 'function') {
|
|
609
614
|
return { ...base, reason: 'persistence-unavailable' };
|
|
615
|
+
}
|
|
610
616
|
let snapshot;
|
|
611
617
|
try {
|
|
612
|
-
snapshot = await stat(id);
|
|
618
|
+
snapshot = await persistence.stat(id);
|
|
613
619
|
}
|
|
614
620
|
catch (error) {
|
|
615
621
|
return { ...base, reason: 'read-failed', message: messageOf(error) };
|
package/lib/types/admin.d.ts
CHANGED
|
@@ -191,6 +191,10 @@ export interface SessionPersistenceStatLike {
|
|
|
191
191
|
/**
|
|
192
192
|
* 只读观察一条会话:一次 stat + 一次头部读,**不解压事件日志**。
|
|
193
193
|
* 会话不存在时返回 undefined。
|
|
194
|
+
*
|
|
195
|
+
* 调用方必须写成 `persistence.stat(id)`:内核实现依赖 `this`
|
|
196
|
+
* (`this.ensureRootEncoding()` / `this.tracker` / `this.findLog`),摘成游离
|
|
197
|
+
* 函数调用会拿到 `this === undefined`,直接抛 TypeError。
|
|
194
198
|
*/
|
|
195
199
|
stat?: ((sessionId: string) => Promise<StoredSessionSnapshotLike | undefined>) | undefined;
|
|
196
200
|
/** 压缩格式(jsonl 后端为 `'zstd'`;未压缩为空字符串)。 */
|