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

Function delay

media/transcoder/test/transcoder.test.js:78–89  ·  view source on GitHub ↗
(test, addMs)

Source from the content-addressed store, hash-verified

76const subtitles2File = `testdata/${testSubtitles2FileName}`;
77
78const delay = async (test, addMs) => {
79 const retries = test.currentRetry();
80 await new Promise(r => setTimeout(r, addMs));
81 // No retry on the first failure.
82 if (retries === 0) return;
83 // See: https://cloud.google.com/storage/docs/exponential-backoff
84 const ms = Math.pow(2, retries) * 10000 + Math.random() * 1000;
85 return new Promise(done => {
86 console.info(`retrying "${test.title}" in ${ms}ms`);
87 setTimeout(done, ms);
88 });
89};
90
91function wait(ms) {
92 return new Promise(resolve => {

Callers 1

transcoder.test.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected