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

Function delay

spanner/system-test/spanner.test.js:129–144  ·  view source on GitHub ↗
(test, cleanupFn = null)

Source from the content-addressed store, hash-verified

127}
128
129const delay = async (test, cleanupFn = null) => {
130 const retries = test.currentRetry();
131 // No retry on the first failure.
132 if (retries === 0) return;
133
134 // run cleanup for database, provided
135 if (cleanupFn) {
136 await cleanupFn();
137 }
138 // See: https://cloud.google.com/storage/docs/exponential-backoff
139 const ms = Math.pow(2, retries) + Math.random() * 1000;
140 return new Promise(done => {
141 console.info(`retrying "${test.title}" in ${ms}ms`);
142 setTimeout(done, ms);
143 });
144};
145
146async function deleteStaleInstances() {
147 let [instances] = await spanner.getInstances({

Callers 1

spanner.test.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected