diff --git a/src/index.ts b/src/index.ts index 132236b..8c7a090 100644 --- a/src/index.ts +++ b/src/index.ts @@ -52,14 +52,15 @@ export class TetherClient { mutation_id: mutation_id })); return new Promise((resolve, reject) => { - this.websocketHandler.onMutation = (mutation_id: string, data: any) => { - if (mutation_id === mutation_id) { + const timeoutId = setTimeout(() => { + reject(new Error('Mutation timeout')); + }, 10000); + this.websocketHandler.onMutation = (incoming_id: string, data: any) => { + if (incoming_id === mutation_id) { + clearTimeout(timeoutId); resolve(data); } }; - setTimeout(() => { - reject(new Error('Mutation timeout')); - }, 10000); }); }; } \ No newline at end of file