good first issuehelp wanted
描述
Describe the bug
The LocalQueueDriver leaks setTimeout in a Promise.race.
To Reproduce Steps to reproduce the behavior:
- Set
continueWaitTimeoutto a high number, 20+ seconds or so. - Make a
loadrequest to Cubejs - Call
shutdownon the server. - Process runs until timeout ends.
Expected behavior Timeout should be canceled if nothing is awaiting it.
In LocalQueueDriver.js,
async getResultBlocking(queryKey) {
const resultListKey = this.resultListKey(queryKey);
if (!this.queryDef[this.redisHash(queryKey)] && !this.resultPromises[resultListKey]) {
return null;
}
const timeoutPromise = (timeout) => new Promise((resolve) => setTimeout(() => resolve(null), timeout));
const res = await Promise.race([
this.getResultPromise(resultListKey),
// LEAKING TIMEOUT HERE
timeoutPromise(this.continueWaitTimeout * 1000),
]);
if (res) {
delete this.resultPromises[resultListKey];
}
return res;
** Example Config **
orchestratorOptions: {
queryCacheOptions: {
queueOptions: {
continueWaitTimeout: 30,
},
},
},