diff --git a/src/application/releaseExposure/ReleaseExposureService.test.ts b/src/application/releaseExposure/ReleaseExposureService.test.ts index 1cfac306d6..b7992396f8 100644 --- a/src/application/releaseExposure/ReleaseExposureService.test.ts +++ b/src/application/releaseExposure/ReleaseExposureService.test.ts @@ -3292,3 +3292,34 @@ describe("ReleaseExposureService parsed field trailing characters", () => { }, ); }); + +it("attempts later release-exposure owners after a synchronous close rejection", async () => { + const { service, desktop, goBinaries, rustBinaries } = owners(scan()); + const failed = new Error("desktop close failed"); + desktop.close.mockImplementationOnce(() => { + throw failed; + }); + await expect(service.close()).rejects.toBe(failed); + expect(goBinaries.close).toHaveBeenCalledOnce(); + expect(rustBinaries.close).toHaveBeenCalledOnce(); +}); + +it("follows the remaining release-exposure owner when a sibling has already released", async () => { + const { service, desktop, goBinaries } = owners(scan()); + const first = new ProviderCleanupError("desktop", ["desktop-root"], {}); + const second = new ProviderCleanupError("go", ["go-root"], {}); + desktop.close.mockRejectedValue(first); + goBinaries.close.mockImplementationOnce(async () => { + releaseOwnedCleanup(first); + throw second; + }); + const failure: unknown = await service + .close() + .catch((cause: unknown) => cause); + if (!(failure instanceof ProviderCleanupError)) + throw new Error("Expected a combined close error"); + expect(failure.cleanupResources).toEqual(["go-root"]); + expect(failure.cleanupIncomplete).toBe(true); + releaseOwnedCleanup(second); + expect(failure.cleanupIncomplete).toBe(false); +}); diff --git a/src/application/releaseExposure/ReleaseExposureService.ts b/src/application/releaseExposure/ReleaseExposureService.ts index 809c314b5b..66c77d9ae4 100644 --- a/src/application/releaseExposure/ReleaseExposureService.ts +++ b/src/application/releaseExposure/ReleaseExposureService.ts @@ -76,7 +76,7 @@ export class ReleaseExposureService { ["rust binaries", () => this.owners.rustBinaries.close()], ] as const; const settled = await Promise.allSettled( - owners.map(([, close]) => close()), + owners.map(async ([, close]) => close()), ); const failures = settled.flatMap((result, index) => { const owner = owners[index]; @@ -588,9 +588,13 @@ const ownerCloseFailure = ( operation: RELEASE_EXPOSURE_OPERATION, }, ); - const live = typed.filter((cause) => cause.cleanupIncomplete); - // An opaque rejection supplies no release authority, so it stays incomplete. - if (live.length === failures.length) aggregate.bindCleanupDependencies(live); + // An owner that already released still accounts for its rejection. An opaque + // rejection supplies no release authority and keeps the aggregate incomplete. + if ( + typed.length === failures.length && + typed.every((cause) => cause.carriesCleanup) + ) + aggregate.bindCleanupDependencies(typed); return aggregate; };