Skip to content

feat: add workflow execution samples with and without arguments#4302

Draft
angelcaamal wants to merge 4 commits intomainfrom
feat/workflow-executions-samples
Draft

feat: add workflow execution samples with and without arguments#4302
angelcaamal wants to merge 4 commits intomainfrom
feat/workflow-executions-samples

Conversation

@angelcaamal
Copy link
Copy Markdown
Contributor

@angelcaamal angelcaamal commented Apr 24, 2026

Description

Fixes #

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

  • I have followed guidelines from CONTRIBUTING.MD and Samples Style Guide
  • Tests pass: npm test (see Testing)
  • Lint pass: npm run lint (see Style)
  • Required CI tests pass (see CI testing)
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • This pull request is from a branch created directly off of GoogleCloudPlatform/nodejs-docs-samples. Not a fork.
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new sample directory, and I created GitHub Actions workflow for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

Note: Any check with (dev), (experimental), or (legacy) can be ignored and should not block your PR from merging (see CI testing).

@angelcaamal angelcaamal added samples Issues that are directly related to samples. api: workflows Issues related to the Workflows API. labels Apr 24, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +88 to +90
} catch (e) {
console.error(`Error executing workflow: ${e}`);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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;
  }

Comment on lines +79 to +81
}
} catch (e) {
console.error(`Error executing workflow: ${e}`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
backoffDelay *= 2; // Double the delay to provide exponential backoff.
backoffDelay = Math.min(backoffDelay * 2, 32000); // Double the delay to provide exponential backoff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: workflows Issues related to the Workflows API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant