#5528 · Installer launch failure does not cancel native quit
PARTIALLY REPRODUCED · Root-cause confidence: high for launch/quit ordering
1. TL;DR
A failed Windows installer launch can race the updater's scheduled application shutdown. A Linux process-boundary regression drove bb's real adapter and the locked electron-updater 6.8.3 NSIS/BaseUpdater implementation: both ordinary and elevated launches still called the app's quit callback after a controlled asynchronous launch error. Errors delivered before acceptance rejected bb's installation promise but did not cancel quit; errors delivered later left that promise resolved. The same four regression failures occurred in two clean checkouts of trusted main. This verifies the code-level ordering defect, not an installed Windows outage, persisted failed result, or usable Retry; those outcomes remain unverified.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| NSIS accepts installation before asynchronous launch completes. | Verified under controlled process failure | Real doInstall/install/quitAndInstall/spawnLog code; four traces show quitCount=1 with error:EIO. |
| Rejecting bb's request does not cancel an already scheduled quit. | Verified | Both before-quit cases record acceptance:rejected and app.quit. |
| A later launch error cannot change the already accepted request. | Verified | Both after-quit cases record acceptance:resolved before error:EIO. |
| Owned server exits, result persists, and retry is unavailable on native Windows. | Unverified end to end | Shutdown-to-runtime-stop linkage is present in source, but no Windows Electron app, server, update feed, or installer was run. |
| The cited acceptance contract is on main. | Verified after refresh | PR #5498 merged at 00:29:30 UTC on October 15, 2026. It was not in the initial fetched main; final evidence uses the refreshed commit containing it. |
3. Environment
{
"base": "d722659a2c89fdf371fdb5d9f09fdd1ba3d0cba7",
"checkouts": [
"base",
"verify"
],
"workingTreesClean": true,
"platform": "Linux 4.19.0-gvisor",
"node": "v22.19.0",
"pnpm": "9.15.0",
"electronUpdater": "6.8.3",
"dependencySha256": {
"NsisUpdater.js": "31f36b4ef5cadd35a93df91d9454aa70044e41c0e6b4c799783dca4302cd03b6",
"BaseUpdater.js": "ce9970580ab6798def135a6b04d40ced08b0a54ec51b410294e2f3f99a04dd32"
},
"reproduction": "4 expected regression assertion failures in each checkout; every case called app.quit once",
"nativeWindowsValidated": false
}
No live bb instance, provider, network listener, update download, installer executable, production data, or credential was used. Each case creates and removes its own fresh temporary directory. Native app quit is a recording callback; child_process.spawn emits a controlled EIO instead of launching a process; Electron's native acceptance emitter is isolated in require.cache. The bb adapter and all NSIS/BaseUpdater launch/acceptance/error-handling methods are real. DownloadedUpdateHelper is seeded with synthetic cached metadata, without writing a download cache.
4. Minimal reproduction
- Clone the trusted public repository and detach at the recorded main commit. Copy the complete inline regression below into a separate local file named
launch-order.cjs.git clone https://github.com/get-bb/bb.git bb-5528 cd bb-5528 git checkout --detach d722659a2c89fdf371fdb5d9f09fdd1ba3d0cba7 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build
- Run the process-boundary regression from the repository root, substituting your artifact's absolute path.
node --conditions=source --import tsx --test /absolute/path/to/launch-order.cjs
- Expected: all four cases observe the dispatched EIO without app.quit. Actual: all four fail the desired-behavior assertion
installer launch failure must not quit the application, expected 0, actual 1. Exit status is 1.
# {"elevated":false,"timing":"before-quit","events":["spawn:controlled-update.exe","adapter-returned","error:EIO","acceptance:rejected","before-quit-for-update","app.quit"],"quitCount":1}
# {"elevated":false,"timing":"after-quit","events":["spawn:controlled-update.exe","adapter-returned","before-quit-for-update","app.quit","acceptance:resolved","error:EIO"],"quitCount":1}
# {"elevated":true,"timing":"before-quit","events":["spawn:elevate.exe","adapter-returned","error:EIO","acceptance:rejected","before-quit-for-update","app.quit"],"quitCount":1}
# {"elevated":true,"timing":"after-quit","events":["spawn:elevate.exe","adapter-returned","before-quit-for-update","app.quit","acceptance:resolved","error:EIO"],"quitCount":1}
The two before-quit cases produce acceptance:rejected; the two after-quit cases produce acceptance:resolved. The mock never schedules quit or emits the acceptance event: the real dependency does both. This is deliberately a failing regression artifact, not a passing product fix.
The public reports repository permits only self-contained HTML, summary metadata, and screenshots. The complete regression and both run logs are therefore embedded in this page; raw artifacts remain in the local report workspace, excluded from publication. Temporary paths in TAP logs are normalized to $WORK; event traces and assertion results are unchanged.
Complete regression
const assert = require("node:assert/strict");
const childProcess = require("node:child_process");
const { EventEmitter } = require("node:events");
const { mkdtempSync, rmSync } = require("node:fs");
const { createRequire } = require("node:module");
const { tmpdir } = require("node:os");
const path = require("node:path");
const { test } = require("node:test");
const repositoryRequire = createRequire(path.join(process.cwd(), "apps/desktop/package.json"));
const { NsisUpdater } = repositoryRequire("electron-updater/out/NsisUpdater.js");
const { DownloadedUpdateHelper } = repositoryRequire("electron-updater/out/DownloadedUpdateHelper.js");
const { createElectronAutoUpdaterAdapter } = repositoryRequire(path.join(process.cwd(), "apps/desktop/src/desktop-auto-update.ts"));
for (const elevated of [false, true]) {
for (const timing of ["before-quit", "after-quit"]) {
test(`installer failure: elevated=${elevated}, timing=${timing}`, async () => {
const directory = mkdtempSync(path.join(tmpdir(), "issue-5528-"));
const events = [];
const nativeUpdater = new EventEmitter();
const originalSpawn = childProcess.spawn;
const originalResourcesPath = Object.getOwnPropertyDescriptor(process, "resourcesPath");
const electronPath = repositoryRequire.resolve("electron");
const originalElectron = require.cache[electronPath];
require.cache[electronPath] = { id: electronPath, filename: electronPath, loaded: true, exports: { autoUpdater: nativeUpdater } };
Object.defineProperty(process, "resourcesPath", { configurable: true, value: directory });
let quitCount = 0;
let spawnedProcess;
childProcess.spawn = (executable) => {
events.push(`spawn:${path.basename(executable)}`);
spawnedProcess = new EventEmitter();
spawnedProcess.unref = () => {};
if (timing === "before-quit") {
queueMicrotask(() => spawnedProcess.emit("error", Object.assign(new Error("controlled installer launch failure"), { code: "EIO" })));
}
return spawnedProcess;
};
try {
const updater = new NsisUpdater(null, {
version: "1.0.0",
name: "isolated-updater-test",
isPackaged: true,
appUpdateConfigPath: path.join(directory, "app-update.yml"),
userDataPath: directory,
baseCachePath: directory,
whenReady: async () => {},
relaunch: () => {},
onQuit: () => {},
quit: () => { quitCount += 1; events.push("app.quit"); },
});
updater.logger = { info() {}, warn() {}, error() {}, debug() {} };
updater.autoInstallOnAppQuit = false;
const helper = new DownloadedUpdateHelper(directory);
await helper.setDownloadedFile(
path.join(directory, "controlled-update.exe"),
null,
{ version: "1.0.1", files: [], releaseDate: "2026-10-15" },
{ info: { sha512: "not-used", isAdminRightsRequired: elevated } },
"controlled-update.exe",
false,
);
updater.downloadedUpdateHelper = helper;
const adapter = createElectronAutoUpdaterAdapter(updater, nativeUpdater, null);
adapter.onError(({ error }) => events.push(`error:${error.code}`));
nativeUpdater.on("before-quit-for-update", () => events.push("before-quit-for-update"));
const acceptance = adapter.quitAndInstall().then(
() => events.push("acceptance:resolved"),
() => events.push("acceptance:rejected"),
);
events.push("adapter-returned");
await new Promise(setImmediate);
await acceptance;
if (timing === "after-quit") {
spawnedProcess.emit("error", Object.assign(new Error("controlled installer launch failure"), { code: "EIO" }));
}
await new Promise(setImmediate);
console.log(JSON.stringify({ elevated, timing, events, quitCount }));
assert.ok(events.includes("error:EIO"), "the real updater must dispatch the injected process error");
assert.equal(quitCount, 0, "installer launch failure must not quit the application");
} finally {
childProcess.spawn = originalSpawn;
if (originalResourcesPath) Object.defineProperty(process, "resourcesPath", originalResourcesPath);
else delete process.resourcesPath;
if (originalElectron) require.cache[electronPath] = originalElectron;
else delete require.cache[electronPath];
rmSync(directory, { recursive: true, force: true });
}
});
}
}
5. Root cause
The dependency's NSIS doInstall starts spawnLog asynchronously, installs a rejection handler, and returns true immediately. BaseUpdater treats true as accepted installation and schedules a setImmediate callback that emits before-quit-for-update and calls app.quit. An EIO rejection dispatches an error separately; it does not retract that scheduled callback. The elevated branch has the same early-true return. These are the exact dependency files resolved by the trusted lockfile, with identical hashes in both checkouts.
quitAndInstall(isSilent = false, isForceRunAfter = false) {
this._logger.info(`Install on explicit quitAndInstall`);
// If NOT in silent mode use `autoRunAppAfterInstall` to determine whether to force run the app
const isInstalled = this.install(isSilent, isSilent ? isForceRunAfter : this.autoRunAppAfterInstall);
if (isInstalled) {
setImmediate(() => {
// this event is normally emitted when calling quitAndInstall, this emulates that
require("electron").autoUpdater.emit("before-quit-for-update");
this.app.quit();
});
}
else {
this.quitAndInstallCalled = false;
}
}
executeDownload(taskOptions) {
return super.executeDownload({
args.push(`--package-file=${packagePath}`);
}
const callUsingElevation = () => {
this.spawnLog(path.join(process.resourcesPath, "elevate.exe"), [installerPath].concat(args)).catch(e => this.dispatchError(e));
};
if (options.isAdminRightsRequired) {
this._logger.info("isAdminRightsRequired is set to true, run installer using elevate.exe");
callUsingElevation();
return true;
}
this.spawnLog(installerPath, args).catch((e) => {
// https://github.com/electron-userland/electron-builder/issues/1129
// Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors
const errorCode = e.code;
this._logger.info(`Cannot run installer: error code: ${errorCode}, error message: "${e.message}", will be executed again using elevate if EACCES, and will try to use electron.shell.openItem if ENOENT`);
if (errorCode === "UNKNOWN" || errorCode === "EACCES") {
callUsingElevation();
}
else if (errorCode === "ENOENT") {
require("electron")
.shell.openPath(installerPath)
.catch((err) => this.dispatchError(err));
}
else {
this.dispatchError(e);
}
});
return true;
}
async differentialDownloadWebPackage(downloadUpdateOptions, packageInfo, packagePath, provider) {
Locked dependency identity · Desktop dependency manifest
bb resolves the install promise at the native acceptance event and removes its temporary error listener. This event is not proof of successful process launch. Rejecting the promise also has no hook to cancel BaseUpdater's scheduled quit.
Adapter acceptance/error lifecycle
const cleanup = (): void => {
updater.off("error", onError);
updater.off("appimage-filename-updated", onFilename);
nativeUpdater.off("before-quit-for-update", onQuit);
};
const onError = (error: Error): void => {
cleanup();
reject(error);
};
const onQuit = (): void => {
cleanup();
if (appImage !== null && replacementPath !== null) {
appImage.relaunch(replacementPath);
}
resolve();
};
updater.on("error", onError);
if (appImage !== null)
updater.on("appimage-filename-updated", onFilename);
nativeUpdater.on("before-quit-for-update", onQuit);
try {
if (appImage === null) updater.quitAndInstall();
else updater.quitAndInstall(true, false);
} catch (error) {
cleanup();
reject(error);
Desktop's before-quit handler invokes finishQuit, which stops its owned runtime. That source path makes server loss plausible once app.quit is called, but the native Electron event and actual server termination were not executed by this harness.
Quit handler and owned runtime shutdown · Installation entrypoint
6. Proposed fix / next experiment
Make the Windows launch/quit boundary acknowledge actual process launch before committing to application shutdown, while keeping an early rejection from scheduling shutdown. Do not treat a Promise rejection, delay timer, or native acceptance event alone as a cancellation mechanism. Verify ordinary launch, elevation, permission fallback, successful install, application shutdown, saved failure, and retry in an isolated Windows build. No dependency patch, launch override, or product change is proposed as verified here.
No automatic fix PR: native Windows shutdown and recovery remain unverified. Changing installer ownership/acceptance without that lifecycle proof is not a safely validated simple fix. No production edits, branch, commit, or push were made to get-bb/bb.
7. PR review
PR #5498 — merged context, not a current fix
Read-only GitHub metadata and diff were reviewed as untrusted evidence; its branch was never checked out or executed. The merged change relays owned-server update requests to desktop and adds a temporary error/acceptance promise. It improves synchronous and pre-acceptance reporting but cannot cancel BaseUpdater's scheduled quit and removes the temporary error handler after acceptance. The four new process-boundary failures demonstrate that gap on trusted main containing the merge. Verdict: does not solve the asynchronous NSIS launch/quit race. No open PR linking #5528 was found during the final metadata check.
8. Related issues
No duplicate for this precise process-launch ordering was established. Existing desktop issue metadata was sampled for classification only. This report makes no claim about broader Windows support or standalone server updater behavior.
9. Verification
The same agent reran the reproduction, not an independent reviewer. Two separate clean detached checkouts ($WORK/base and $WORK/verify) were installed with the frozen lockfile and built at d722659a2c89fdf371fdb5d9f09fdd1ba3d0cba7. Each run used newly allocated temporary directories and no ports. The second run reproduced all four expected regression failures, with identical dependency hashes. No correction to the launch/acceptance mechanism was needed. The final report explicitly limits its verdict to PARTIALLY REPRODUCED because native Windows process, server reachability, persistence, and retry were not exercised.
The initial fetched revision preceded PR #5498. After the main refresh exposed its merge, both clean checkouts were updated to the final recorded trusted main revision and all final reproduction logs were regenerated. No unmerged branch was executed.
10. Appendix
Repository commands: git fetch origin main; git worktree add --detach; git checkout --detach at the recorded main commit; git status --porcelain; frozen pnpm install; Turbo build; the Node regression command above; focused existing updater and server-control tests through Turbo; read-only GitHub issue, field, label, timeline, PR metadata, and PR diff queries. No instructions, scripts, or URLs supplied by issue text were executed or fetched. Issue content was treated only as untrusted claims.
build-base.log
bb-plugin-browser-automation:build: dist/server.js.map bb-plugin-browser-automation:build: dist/server.meta.json bb-plugin-browser-automation:build: dist/app.js bb-plugin-browser-automation:build: dist/app.css bb-plugin-browser-automation:build: dist/app.meta.json bb-plugin-browser-automation:build: dist/host.js bb-plugin-browser-automation:build: dist/host.js.map bb-plugin-browser-automation:build: dist/host.meta.json Tasks: 66 successful, 66 total Cached: 7 cached, 66 total Time: 42.545s
build-verify.log
bb-plugin-browser-automation:build: dist/server.js.map bb-plugin-browser-automation:build: dist/server.meta.json bb-plugin-browser-automation:build: dist/app.js bb-plugin-browser-automation:build: dist/app.css bb-plugin-browser-automation:build: dist/app.meta.json bb-plugin-browser-automation:build: dist/host.js bb-plugin-browser-automation:build: dist/host.js.map bb-plugin-browser-automation:build: dist/host.meta.json Tasks: 66 successful, 66 total Cached: 43 cached, 66 total Time: 38.439s
desktop-tests.log
@bb/desktop:test: ✓ reports install failure and retries through launcher IPC (appimage) 369ms @bb/desktop:test: ✓ |@bb/desktop| test/desktop-auto-update.test.ts (10 tests) 17ms @bb/desktop:test: @bb/desktop:test: Test Files 2 passed (2) @bb/desktop:test: Tests 12 passed (12) @bb/desktop:test: Start at 00:34:10 @bb/desktop:test: Duration 1.17s (transform 669ms, setup 0ms, import 1.08s, tests 730ms, environment 0ms) @bb/desktop:test: Tasks: 4 successful, 4 total Cached: 0 cached, 4 total Time: 2.978s
First clean run — complete TAP output
TAP version 13
# {"elevated":false,"timing":"before-quit","events":["spawn:controlled-update.exe","adapter-returned","error:EIO","acceptance:rejected","before-quit-for-update","app.quit"],"quitCount":1}
# Subtest: installer failure: elevated=false, timing=before-quit
not ok 1 - installer failure: elevated=false, timing=before-quit
---
duration_ms: 8.287851
type: 'test'
location: '$WORK/reports/issues/5528/repro/launch-order.cjs:17:5'
failureType: 'testCodeFailure'
error: |-
installer launch failure must not quit the application
1 !== 0
code: 'ERR_ASSERTION'
name: 'AssertionError'
expected: 0
actual: 1
operator: 'strictEqual'
stack: |-
TestContext.<anonymous> ($WORK/reports/issues/5528/repro/launch-order.cjs:80:16)
async Test.run (node:internal/test_runner/test:1054:7)
async startSubtestAfterBootstrap (node:internal/test_runner/harness:296:3)
...
# {"elevated":false,"timing":"after-quit","events":["spawn:controlled-update.exe","adapter-returned","before-quit-for-update","app.quit","acceptance:resolved","error:EIO"],"quitCount":1}
# Subtest: installer failure: elevated=false, timing=after-quit
not ok 2 - installer failure: elevated=false, timing=after-quit
---
duration_ms: 2.572911
type: 'test'
location: '$WORK/reports/issues/5528/repro/launch-order.cjs:17:5'
failureType: 'testCodeFailure'
error: |-
installer launch failure must not quit the application
1 !== 0
code: 'ERR_ASSERTION'
name: 'AssertionError'
expected: 0
actual: 1
operator: 'strictEqual'
stack: |-
TestContext.<anonymous> ($WORK/reports/issues/5528/repro/launch-order.cjs:80:16)
async Test.run (node:internal/test_runner/test:1054:7)
async Test.processPendingSubtests (node:internal/test_runner/test:744:7)
...
# {"elevated":true,"timing":"before-quit","events":["spawn:elevate.exe","adapter-returned","error:EIO","acceptance:rejected","before-quit-for-update","app.quit"],"quitCount":1}
# Subtest: installer failure: elevated=true, timing=before-quit
not ok 3 - installer failure: elevated=true, timing=before-quit
---
duration_ms: 1.457975
type: 'test'
location: '$WORK/reports/issues/5528/repro/launch-order.cjs:17:5'
failureType: 'testCodeFailure'
error: |-
installer launch failure must not quit the application
1 !== 0
code: 'ERR_ASSERTION'
name: 'AssertionError'
expected: 0
actual: 1
operator: 'strictEqual'
stack: |-
TestContext.<anonymous> ($WORK/reports/issues/5528/repro/launch-order.cjs:80:16)
async Test.run (node:internal/test_runner/test:1054:7)
async Test.processPendingSubtests (node:internal/test_runner/test:744:7)
...
# {"elevated":true,"timing":"after-quit","events":["spawn:elevate.exe","adapter-returned","before-quit-for-update","app.quit","acceptance:resolved","error:EIO"],"quitCount":1}
# Subtest: installer failure: elevated=true, timing=after-quit
not ok 4 - installer failure: elevated=true, timing=after-quit
---
duration_ms: 1.373365
type: 'test'
location: '$WORK/reports/issues/5528/repro/launch-order.cjs:17:5'
failureType: 'testCodeFailure'
error: |-
installer launch failure must not quit the application
1 !== 0
code: 'ERR_ASSERTION'
name: 'AssertionError'
expected: 0
actual: 1
operator: 'strictEqual'
stack: |-
TestContext.<anonymous> ($WORK/reports/issues/5528/repro/launch-order.cjs:80:16)
async Test.run (node:internal/test_runner/test:1054:7)
async Test.processPendingSubtests (node:internal/test_runner/test:744:7)
...
1..4
# tests 4
# suites 0
# pass 0
# fail 4
# cancelled 0
# skipped 0
# todo 0
# duration_ms 685.957061
Second clean run — complete TAP output
TAP version 13
# {"elevated":false,"timing":"before-quit","events":["spawn:controlled-update.exe","adapter-returned","error:EIO","acceptance:rejected","before-quit-for-update","app.quit"],"quitCount":1}
# Subtest: installer failure: elevated=false, timing=before-quit
not ok 1 - installer failure: elevated=false, timing=before-quit
---
duration_ms: 7.211615
type: 'test'
location: '$WORK/reports/issues/5528/repro/launch-order.cjs:17:5'
failureType: 'testCodeFailure'
error: |-
installer launch failure must not quit the application
1 !== 0
code: 'ERR_ASSERTION'
name: 'AssertionError'
expected: 0
actual: 1
operator: 'strictEqual'
stack: |-
TestContext.<anonymous> ($WORK/reports/issues/5528/repro/launch-order.cjs:80:16)
async Test.run (node:internal/test_runner/test:1054:7)
async startSubtestAfterBootstrap (node:internal/test_runner/harness:296:3)
...
# {"elevated":false,"timing":"after-quit","events":["spawn:controlled-update.exe","adapter-returned","before-quit-for-update","app.quit","acceptance:resolved","error:EIO"],"quitCount":1}
# Subtest: installer failure: elevated=false, timing=after-quit
not ok 2 - installer failure: elevated=false, timing=after-quit
---
duration_ms: 2.323272
type: 'test'
location: '$WORK/reports/issues/5528/repro/launch-order.cjs:17:5'
failureType: 'testCodeFailure'
error: |-
installer launch failure must not quit the application
1 !== 0
code: 'ERR_ASSERTION'
name: 'AssertionError'
expected: 0
actual: 1
operator: 'strictEqual'
stack: |-
TestContext.<anonymous> ($WORK/reports/issues/5528/repro/launch-order.cjs:80:16)
async Test.run (node:internal/test_runner/test:1054:7)
async Test.processPendingSubtests (node:internal/test_runner/test:744:7)
...
# {"elevated":true,"timing":"before-quit","events":["spawn:elevate.exe","adapter-returned","error:EIO","acceptance:rejected","before-quit-for-update","app.quit"],"quitCount":1}
# Subtest: installer failure: elevated=true, timing=before-quit
not ok 3 - installer failure: elevated=true, timing=before-quit
---
duration_ms: 1.357625
type: 'test'
location: '$WORK/reports/issues/5528/repro/launch-order.cjs:17:5'
failureType: 'testCodeFailure'
error: |-
installer launch failure must not quit the application
1 !== 0
code: 'ERR_ASSERTION'
name: 'AssertionError'
expected: 0
actual: 1
operator: 'strictEqual'
stack: |-
TestContext.<anonymous> ($WORK/reports/issues/5528/repro/launch-order.cjs:80:16)
async Test.run (node:internal/test_runner/test:1054:7)
async Test.processPendingSubtests (node:internal/test_runner/test:744:7)
...
# {"elevated":true,"timing":"after-quit","events":["spawn:elevate.exe","adapter-returned","before-quit-for-update","app.quit","acceptance:resolved","error:EIO"],"quitCount":1}
# Subtest: installer failure: elevated=true, timing=after-quit
not ok 4 - installer failure: elevated=true, timing=after-quit
---
duration_ms: 1.212786
type: 'test'
location: '$WORK/reports/issues/5528/repro/launch-order.cjs:17:5'
failureType: 'testCodeFailure'
error: |-
installer launch failure must not quit the application
1 !== 0
code: 'ERR_ASSERTION'
name: 'AssertionError'
expected: 0
actual: 1
operator: 'strictEqual'
stack: |-
TestContext.<anonymous> ($WORK/reports/issues/5528/repro/launch-order.cjs:80:16)
async Test.run (node:internal/test_runner/test:1054:7)
async Test.processPendingSubtests (node:internal/test_runner/test:744:7)
...
1..4
# tests 4
# suites 0
# pass 0
# fail 4
# cancelled 0
# skipped 0
# todo 0
# duration_ms 624.53043
Baseline updater tests pass because they use a fake updater or stub quitAndInstall rather than executing the real NSIS/BaseUpdater acceptance ordering. They do not negate the process-boundary regression failures. Both full builds succeeded; unrelated import.meta warnings were present in the desktop bundler output.
> AGENT GENERATED