fix(maps): settle failed recovery and update registry QA

This commit is contained in:
Sameh Khamis committed 2026-09-13 19:01:23 -07:00
1 parent 06c73bca98
commit 8024813792
4 files changed
+145 -300

No files matched your search

+9 -3
View File
@@ -124,9 +124,15 @@ export class MapSourceController {
recovery.id !== stack.id &&
this.isStackAvailable(recovery.id)
) {
await this._activate(recovery, gen);
if (gen !== this._switchGen) return this.getState();
this._activeId = recovery.id;
try {
const activation = await this._activate(recovery, gen);
if (gen !== this._switchGen) return this.getState();
this._activeId = activation?.effectiveStackId || recovery.id;
} catch (recoveryError) {
if (gen !== this._switchGen) return this.getState();
this._lastError = recoveryError?.message || String(recoveryError);
this._onError?.(this._lastError, recovery);
}
}
if (!silent) this._emitChange('error');
} finally {
+32
View File
@@ -349,3 +349,35 @@ for (const reactivate of [false, true]) {
assert.equal(destroyed, 1);
});
}
test('a failed recovery reports its error and leaves switching settled', async () => {
const errors = [];
const env = fixture(
{
defaultId: 'first',
recoveryId: 'recovery',
sources: [
{
descriptor: descriptor('first'),
imagery: async () => {
throw new Error('first offline');
},
},
{
descriptor: descriptor('recovery'),
imagery: async () => {
throw new Error('recovery offline');
},
},
],
},
{ onError: (message) => errors.push(message) },
);
const result = await env.controller.setStack('first');
assert.equal(result.status, 'ready');
assert.equal(result.lastError, 'recovery offline');
assert.deepEqual(errors, ['first offline', 'recovery offline']);
assert.equal(env.changes.at(-1).status, 'error');
assert.equal(env.imagery.length, 0);
env.controller.destroy();
});