mirror of
https://github.com/morluto/rea.git
synced 2026-11-20 13:45:30 +00:00
fix(release): finish closing exposure readers after individual failures (#12583)
This commit is contained in:
2 files changed
+39
-4
No files matched your search
@@ -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);
|
||||
});
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user