Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,31 @@ describe('RunT0ReviewOrchestration', () => {
expect(fixture.dependencies.invocations.prepare).not.toHaveBeenCalled();
});

it('releases a lease acquired concurrently with pull request closure', async () => {
const fixture = createFixture();
jest
.mocked(fixture.dependencies.revisionGuard.loadCurrentRevision)
.mockImplementation(async () =>
fixture.controlPlane.acquireInvocationLease.mock.calls.length === 0
? revisionOf(fixture.command)
: {
...revisionOf(fixture.command),
pullRequestState: 'closed',
}
);

const result = await fixture.useCase.execute(fixture.command);

expect(result.status).toBe(ReviewOrchestrationResultStatus.Cancelled);
expect(fixture.controlPlane.acquireInvocationLease).toHaveBeenCalledTimes(
1
);
expect(fixture.controlPlane.releaseInvocationLease).toHaveBeenCalledTimes(
1
);
expect(fixture.dependencies.invocations.execute).not.toHaveBeenCalled();
});

it('releases the lease and supersedes when revision moves after provider execution', async () => {
const fixture = createFixture();
jest
Expand Down
15 changes: 10 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97303,11 +97303,16 @@ var RunT0ReviewOrchestration = class {
};
}
}
input.onEvent({
type: "slot_lease_acquired" /* SlotLeaseAcquired */,
workSlotId: input.workSlot.workSlotId
});
await this.assertRevisionCurrent(input.revision);
try {
input.onEvent({
type: "slot_lease_acquired" /* SlotLeaseAcquired */,
workSlotId: input.workSlot.workSlotId
});
await this.assertRevisionCurrent(input.revision);
} catch (error2) {
await this.releaseLease(lease, input.ownerIdHash, attemptOrdinal);
throw error2;
}
if (!this.canStartInvocation(attemptOrdinal)) {
await this.releaseLease(lease, input.ownerIdHash, attemptOrdinal);
input.onEvent({
Expand Down
Loading
Loading