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 @@ -141,11 +141,9 @@ describe('AbstractExecutionService', () => {
).rejects.toThrow(`"${MOCK_SNAP_ID}" is already running.`);
});

it('throws an error if the Snap is not running when attempted to be terminated', async () => {
it('does nothing if the Snap is not running when attempted to be terminated', async () => {
const { service } = createService(MockExecutionService);

await expect(service.terminateSnap(MOCK_SNAP_ID)).rejects.toThrow(
`"${MOCK_SNAP_ID}" is not currently running.`,
);
expect(await service.terminateSnap(MOCK_SNAP_ID)).toBeUndefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,14 @@ export abstract class AbstractExecutionService<WorkerType>
/**
* Terminates the Snap with the specified ID and deletes all its associated
* data. Any subsequent messages targeting the Snap will fail with an error.
* Throws an error if the specified Snap does not exist, or if termination
* fails unexpectedly.
* Throws an error if termination fails unexpectedly.
*
* @param snapId - The id of the Snap to be terminated.
*/
public async terminateSnap(snapId: string): Promise<void> {
const job = this.#jobs.get(snapId);
if (!job) {
throw new Error(`"${snapId}" is not currently running.`);
return;
}

try {
Expand Down
Loading