Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
fix: call getOrder using async instead of Promise
Browse files Browse the repository at this point in the history
This resolves the "Order does not exist" error not being handled by
catch block.

Fixes: #26
  • Loading branch information
tony-ho committed Feb 16, 2021
1 parent f371bce commit 440d092
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/binance-oco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const binanceOco = async (

const waitForBuyOrderFill = (buyOrderId: number): Promise<string> => {
return new Promise(
(resolve, reject): void => {
async (resolve, reject): Promise<void> => {
try {
disconnect = binance.ws.trades(
pair,
Expand Down Expand Up @@ -269,19 +269,14 @@ export const binanceOco = async (
}
);

binance
.getOrder({
symbol: pair,
orderId: buyOrderId
})
.then(
(response): void => {
if (response.status === "FILLED") {
// Binance API doesn't provide commission asset information; default to BNB
resolve("BNB");
}
}
);
const response = await binance.getOrder({
symbol: pair,
orderId: buyOrderId
});
if (response.status === "FILLED") {
// Binance API doesn't provide commission asset information; default to BNB
resolve("BNB");
}
} catch (err) {
if (err.code === ErrorCodes.NO_SUCH_ORDER) {
// Order information may not yet be available via Binance REST API.
Expand Down

0 comments on commit 440d092

Please sign in to comment.