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

Function delay

compute/test/samples.test.js:38–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36// See examples like: https://github.com/googleapis/nodejs-monitoring/issues/190,
37// https://github.com/googleapis/nodejs-monitoring/issues/191.
38const delay = async test => {
39 const retries = test.currentRetry();
40 if (retries === 0) return; // no retry on the first failure.
41 // see: https://cloud.google.com/storage/docs/exponential-backoff:
42 const ms = Math.pow(2, retries) * 500 + Math.random() * 1000;
43 return new Promise(done => {
44 console.info(`retrying "${test.title}" in ${ms}ms`);
45 setTimeout(done, ms);
46 });
47};
48
49const getInstance = async (projectId, zone, instanceName) => {
50 const [instance] = await instancesClient.get({

Callers 1

samples.test.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected