fix(FN-2316): harden pi session message normalization
This commit is contained in:
@@ -598,13 +598,11 @@ describe("MissionStore", () => {
|
|||||||
expect(events.events[0]).toEqual(event);
|
expect(events.events[0]).toEqual(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("getMissionEvents supports pagination, filtering, and newest-first ordering", async () => {
|
it("getMissionEvents supports pagination, filtering, and newest-first ordering", () => {
|
||||||
const mission = store.createMission({ title: "Events mission" });
|
const mission = store.createMission({ title: "Events mission" });
|
||||||
|
|
||||||
const first = store.logMissionEvent(mission.id, "mission_started", "first");
|
const first = store.logMissionEvent(mission.id, "mission_started", "first");
|
||||||
await new Promise((resolve) => setTimeout(resolve, 5));
|
|
||||||
const second = store.logMissionEvent(mission.id, "warning", "second warning");
|
const second = store.logMissionEvent(mission.id, "warning", "second warning");
|
||||||
await new Promise((resolve) => setTimeout(resolve, 5));
|
|
||||||
const third = store.logMissionEvent(mission.id, "error", "third error");
|
const third = store.logMissionEvent(mission.id, "error", "third error");
|
||||||
|
|
||||||
const pageOne = store.getMissionEvents(mission.id, { limit: 2, offset: 0 });
|
const pageOne = store.getMissionEvents(mission.id, { limit: 2, offset: 0 });
|
||||||
|
|||||||
@@ -937,7 +937,7 @@ export class MissionStore extends EventEmitter<MissionStoreEvents> {
|
|||||||
SELECT *
|
SELECT *
|
||||||
FROM mission_events
|
FROM mission_events
|
||||||
WHERE ${whereSql}
|
WHERE ${whereSql}
|
||||||
ORDER BY timestamp DESC, id DESC
|
ORDER BY COALESCE(seq, 0) DESC, timestamp DESC, id DESC
|
||||||
LIMIT ? OFFSET ?
|
LIMIT ? OFFSET ?
|
||||||
`).all(...params, limit, offset) as unknown as MissionEventRow[];
|
`).all(...params, limit, offset) as unknown as MissionEventRow[];
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
* - Error isolation (plugin crashes don't crash the loader)
|
* - Error isolation (plugin crashes don't crash the loader)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { randomUUID } from "node:crypto";
|
||||||
import { copyFile, unlink } from "node:fs/promises";
|
import { copyFile, unlink } from "node:fs/promises";
|
||||||
import { isAbsolute, parse, resolve } from "node:path";
|
import { isAbsolute, parse, resolve } from "node:path";
|
||||||
import { pathToFileURL } from "node:url";
|
import { pathToFileURL } from "node:url";
|
||||||
@@ -278,7 +279,7 @@ export class PluginLoader extends EventEmitter<{
|
|||||||
const parsed = parse(path);
|
const parsed = parse(path);
|
||||||
tempPath = resolve(
|
tempPath = resolve(
|
||||||
parsed.dir,
|
parsed.dir,
|
||||||
`${parsed.name}.fusion-import-${process.pid}-${++this.importNonce}${parsed.ext || ".js"}`,
|
`${parsed.name}.fusion-import-${process.pid}-${++this.importNonce}-${randomUUID()}${parsed.ext || ".js"}`,
|
||||||
);
|
);
|
||||||
await copyFile(path, tempPath);
|
await copyFile(path, tempPath);
|
||||||
importPath = tempPath;
|
importPath = tempPath;
|
||||||
|
|||||||
Reference in New Issue
Block a user