We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f63c6c6 commit 387998dCopy full SHA for 387998d
b2AuthorizeCfWorker.py
@@ -77,8 +77,29 @@
77
method: request.method,
78
headers: b2Headers
79
})
80
-const response = await fetch(modRequest)
+let response
81
+let i = 3
82
+do {
83
+ response = await timeoutPromise(fetch(modRequest), 2000000)
84
+} while ((!response || !response.ok) && --i)
85
return response
86
+function timeoutPromise(promise, ms) {
87
+ return new Promise((resolve, reject) => {
88
+ const timeoutId = setTimeout(() => {
89
+ reject(new Error("promise timeout"))
90
+ }, ms);
91
+ promise.then(
92
+ (res) => {
93
+ clearTimeout(timeoutId);
94
+ resolve(res);
95
+ },
96
+ (err) => {
97
98
+ reject(err);
99
+ }
100
+ );
101
+ })
102
+}
103
}"""
104
105
workerCode = workerTemplate.replace('<B2_DOWNLOAD_TOKEN>', bDownAuToken)
0 commit comments