Skip to content

Commit ff94849

Browse files
fix: reject promises when ipc send fails (#9)
* fix: reject promises when ipc send fails * chore: upgrade deno_namedpipe to 0.0.3 Co-authored-by: DjDeveloper <[email protected]>
1 parent e473d41 commit ff94849

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.vscode/
2+
.DS_Store

deps.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { connect } from "https://deno.land/x/[email protected].2/mod.ts";
1+
export { connect } from "https://deno.land/x/[email protected].3/mod.ts";

src/conn.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export class DiscordIPC {
108108
args,
109109
nonce,
110110
evt,
111-
});
111+
}).catch(reject);
112112
});
113113
}
114114

@@ -120,7 +120,9 @@ export class DiscordIPC {
120120
login(clientID: string) {
121121
return new Promise<ReadyEventPayload>((resolve, reject) => {
122122
this.#readyHandle = { resolve, reject };
123-
this.send(OpCode.HANDSHAKE, { v: "1", client_id: clientID });
123+
this.send(OpCode.HANDSHAKE, { v: "1", client_id: clientID }).catch(
124+
reject,
125+
);
124126
});
125127
}
126128

src/util.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export async function findIPC(id = 0): Promise<Deno.Conn> {
3838
});
3939
}
4040
} catch (_) {
41-
return findIPC(id + 1);
41+
if (id < 10) {
42+
return findIPC(id + 1);
43+
} else {
44+
throw new Error("Could not connect");
45+
}
4246
}
4347
}

0 commit comments

Comments
 (0)