-
-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw an error for concurrent waits (with nice docs link) (#1618)
* WIP preventing concurrent waits, throw an error * Added ConcurrentWaitError (not retryable) * Move preventMultipleWaits out of the RuntimeAPI * Added preventMultipleWaits to the devRuntimeManager * Added throwable InternalError. Plus new TASK_DID_CONCURRENT_WAIT code * Docs link for troubleshooting concurrent waits * Docs for troubleshooting concurrent waits * preventMultipleWaits function * Added TASK_DID_CONCURRENT_WAIT code * Deal with InternalErrors that skipRetrying * Added preventMultipleWaits to prod
- Loading branch information
1 parent
2ad664d
commit dd321e3
Showing
10 changed files
with
221 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { InternalError } from "../errors.js"; | ||
import { TaskRunErrorCodes } from "../schemas/common.js"; | ||
|
||
const concurrentWaitErrorMessage = | ||
"Parallel waits are not supported, e.g. using Promise.all() around our wait functions."; | ||
|
||
export function preventMultipleWaits() { | ||
let isExecutingWait = false; | ||
|
||
return async <T>(cb: () => Promise<T>): Promise<T> => { | ||
if (isExecutingWait) { | ||
console.error(concurrentWaitErrorMessage); | ||
throw new InternalError({ | ||
code: TaskRunErrorCodes.TASK_DID_CONCURRENT_WAIT, | ||
message: concurrentWaitErrorMessage, | ||
skipRetrying: true, | ||
showStackTrace: false, | ||
}); | ||
} | ||
|
||
isExecutingWait = true; | ||
|
||
try { | ||
return await cb(); | ||
} finally { | ||
isExecutingWait = false; | ||
} | ||
}; | ||
} |
Oops, something went wrong.