Skip to content

An open-source, self-hosted system for apps built with web technologies.

A reinstall starts the Program's startup launch again, so what starts with the System keeps running

zohayrslilehab6a2c431af6
diff --git a/source/server/core/link-manager/auth-manager/program-manager/program-manager.ts b/source/server/core/link-manager/auth-manager/program-manager/program-manager.ts
index 4144ff3..70a5137 100644
--- a/source/server/core/link-manager/auth-manager/program-manager/program-manager.ts
+++ b/source/server/core/link-manager/auth-manager/program-manager/program-manager.ts
@@ -1150,6 +1150,20 @@ export default class ProgramManager extends TheLink {
await this.announcePermissions(entry)
}
+ // A reinstall ended every Process of the Program, its startup one too. That one
+ // starts again as it would with the System, so what starts with the System keeps running.
+ if (!createdHere) {
+
+ try {
+
+ const startup = await this.startup(entry.program, "get")
+
+ if (startup) await this.start(entry.program, startup, undefined, null, true)
+ }
+
+ catch (exception) { console.log(`programs: ${entry.identity} did not start — ${exception instanceof Error ? exception.message : "invalid startup settings"}`) }
+ }
+
if (requestedLaunch !== undefined) {
await this.start(entry.program, requestedLaunch, undefined, null, true)
}
diff --git a/tests/program-installation-lifecycle.test.ts b/tests/program-installation-lifecycle.test.ts
index 3989fef..4e9bea7 100644
--- a/tests/program-installation-lifecycle.test.ts
+++ b/tests/program-installation-lifecycle.test.ts
@@ -114,6 +114,20 @@ test("an omitted installation launch uses installLaunch and false disables it",
expect(start.mock.calls.map(([, launch]) => launch.name)).toEqual(["welcome"])
})
+test("a reinstall starts the Program's startup launch again, as the System does when it starts", async context => {
+ const { manager, definition } = fixture(context)
+ const start = vi.spyOn(manager as unknown as { start(program: Program, launch: Launch, watching?: unknown, parent?: unknown, transitionOwnsIdentity?: boolean): Promise<string> }, "start").mockResolvedValue("process")
+
+ const first = await manager.install(definition())
+ await manager.startup(first.program, "enable", { name: "panel" })
+ await manager.install(definition())
+
+ // The first install had no startup launch; the reinstall ended the Processes and starts that one again.
+ expect(start.mock.calls.map(([, launch]) => launch.name)).toEqual(["panel"])
+ // Still inside the reinstall, which owns the Program's identity until it returns.
+ expect(start.mock.calls[0]?.[4]).toBe(true)
+})
+
test("explicit launch errors propagate without rolling back the installed Program", async context => {
const { manager, definition } = fixture(context)
const start = vi.spyOn(manager as unknown as { start(program: Program, launch: Launch): Promise<string> }, "start")