Skip to content

Commit d8c0082

Browse files
fix: Show different error message for cancelled requests when Snap is stopped
1 parent 7a1340b commit d8c0082

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/snaps-controllers/src/snaps/SnapController.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1947,7 +1947,7 @@ describe('SnapController', () => {
19471947
expect(results[0].status).toBe('fulfilled');
19481948
expect(results[1].status).toBe('rejected');
19491949
expect((results[1] as PromiseRejectedResult).reason.message).toBe(
1950-
`${snap.id} failed to respond to the request in time.`,
1950+
`${snap.id} has been stopped and the request was cancelled.`,
19511951
);
19521952

19531953
snapController.destroy();

packages/snaps-controllers/src/snaps/SnapController.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3642,7 +3642,13 @@ export class SnapController extends BaseController<
36423642
const result = await withTimeout(handleRpcRequestPromise, timer);
36433643

36443644
if (result === hasTimedOut) {
3645-
throw new Error(`${snapId} failed to respond to the request in time.`);
3645+
const stopping =
3646+
runtime.stopPromise !== null || !this.isRunning(snapId);
3647+
throw new Error(
3648+
stopping
3649+
? `${snapId} has been stopped and the request was cancelled.`
3650+
: `${snapId} failed to respond to the request in time.`,
3651+
);
36463652
}
36473653

36483654
await this.#assertSnapRpcResponse(snapId, handlerType, result);

0 commit comments

Comments
 (0)