feat: add workflow execution samples with and without arguments#4302
feat: add workflow execution samples with and without arguments#4302angelcaamal wants to merge 4 commits intomainfrom
Conversation
Increased the timeout to account for the latency of workflow execution and polling.
There was a problem hiding this comment.
Code Review
This pull request introduces new JavaScript and TypeScript samples for executing Google Cloud Workflows with and without arguments, along with corresponding tests and configuration updates. The feedback highlights critical issues in error handling where caught errors are not rethrown, preventing the process from exiting with a failure code. Additionally, it is recommended to cap the exponential backoff delay during execution polling to avoid excessively long wait times.
| } catch (e) { | ||
| console.error(`Error executing workflow: ${e}`); | ||
| } |
There was a problem hiding this comment.
The error is caught and logged, but not rethrown. This causes the promise returned by executeWorkflow to resolve successfully with undefined even when an error occurs. As a result, the caller's .catch() block at line 93 will not be triggered, and the process will exit with a success code (0) instead of an error code (1).
} catch (e) {
console.error(`Error executing workflow: ${e}`);
throw e;
}| } | ||
| } catch (e) { | ||
| console.error(`Error executing workflow: ${e}`); |
There was a problem hiding this comment.
The error is caught and logged, but not rethrown. This causes the promise returned by executeWorkflow to resolve successfully with undefined even when an error occurs. As a result, the caller's .catch() block at line 85 will not be triggered, and the process will exit with a success code (0) instead of an error code (1).
} catch (e) {
console.error(`Error executing workflow: ${e}`);
throw e;
}| if (!executionFinished) { | ||
| console.log('- Waiting for results...'); | ||
| await sleep(backoffDelay); | ||
| backoffDelay *= 2; // Double the delay to provide exponential backoff. |
There was a problem hiding this comment.
It is a best practice to cap the exponential backoff delay to prevent excessively long wait times between polling attempts if the workflow execution takes a significant amount of time.
| backoffDelay *= 2; // Double the delay to provide exponential backoff. | |
| backoffDelay = Math.min(backoffDelay * 2, 32000); // Double the delay to provide exponential backoff. |
| if (!executionFinished) { | ||
| console.log('- Waiting for results...'); | ||
| await sleep(backoffDelay); | ||
| backoffDelay *= 2; // Double the delay to provide exponential backoff. |
There was a problem hiding this comment.
It is a best practice to cap the exponential backoff delay to prevent excessively long wait times between polling attempts if the workflow execution takes a significant amount of time.
| backoffDelay *= 2; // Double the delay to provide exponential backoff. | |
| backoffDelay = Math.min(backoffDelay * 2, 32000); // Double the delay to provide exponential backoff. |
Description
Fixes #
Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.
Checklist
npm test(see Testing)npm run lint(see Style)GoogleCloudPlatform/nodejs-docs-samples. Not a fork.