MCPcopy
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / delay

Function delay

genai/test/util.js:18–27  ·  view source on GitHub ↗
(test)

Source from the content-addressed store, hash-verified

16// retrying with a backoff is a good strategy:
17module.exports = {
18 async delay(test) {
19 const retries = test.currentRetry();
20 if (retries === 0) return; // no retry on the first failure.
21 // see: https://cloud.google.com/storage/docs/exponential-backoff:
22 const ms = Math.pow(2, retries) * 1000 + Math.random() * 2000;
23 return new Promise(done => {
24 console.info(`retrying "${test.title}" in ${ms}ms`);
25 setTimeout(done, ms);
26 });
27 },
28};

Calls

no outgoing calls

Tested by

no test coverage detected