Skip to content

Commit 31c36f5

Browse files
committed
Refactor to async function
1 parent 8af9dfb commit 31c36f5

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/main.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -474,22 +474,24 @@ export function runTaskListInternal(
474474
}
475475
}
476476

477-
function release() {
477+
async function release() {
478478
// No need to call changeListener.release() because the client errored
479479
changeListener = null;
480480
client.removeListener("notification", handleNotification);
481481
// TODO: ideally we'd only stop handling errors once all pending queries are complete; but either way we shouldn't try again!
482482
client.removeListener("error", onErrorReleaseClientAndTryAgain);
483483
events.emit("pool:listen:release", { workerPool, client });
484-
return client
485-
.query('UNLISTEN "jobs:insert"; UNLISTEN "worker:migrate";')
486-
.catch((error) => {
487-
/* ignore errors */
488-
logger.error(`Error occurred attempting to UNLISTEN: ${error}`, {
489-
error,
490-
});
491-
})
492-
.then(() => releaseClient());
484+
try {
485+
await client.query(
486+
'UNLISTEN "jobs:insert"; UNLISTEN "worker:migrate";',
487+
);
488+
} catch (error) {
489+
/* ignore errors */
490+
logger.error(`Error occurred attempting to UNLISTEN: ${error}`, {
491+
error,
492+
});
493+
}
494+
return releaseClient();
493495
}
494496

495497
// On error, release this client and try again

0 commit comments

Comments
 (0)