Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Add download file timeout

Chocobozzz1d0fdb98642a
diff --git a/apps/peertube-runner/CHANGELOG.md b/apps/peertube-runner/CHANGELOG.md
index 8c23442796..64f7df6629 100644
--- a/apps/peertube-runner/CHANGELOG.md
+++ b/apps/peertube-runner/CHANGELOG.md
@@ -1,5 +1,10 @@
# Changelog
+## v0.1.3
+
+ * Disable log coloring when TTY does not support it
+ * Add download file timeout (2 hours) to prevent stuck jobs
+
## v0.1.2
* Support query params in custom upload URL
diff --git a/apps/peertube-runner/src/shared/http.ts b/apps/peertube-runner/src/shared/http.ts
index 5c029ab214..9c6f63e396 100644
--- a/apps/peertube-runner/src/shared/http.ts
+++ b/apps/peertube-runner/src/shared/http.ts
@@ -41,6 +41,14 @@ export function downloadFile (options: {
}
const file = createWriteStream(destination)
+
+ file.on('error', err => {
+ remove(destination)
+ .catch(err => logger.error(err))
+
+ return rej(err)
+ })
+
file.on('finish', () => res())
response.pipe(file)
@@ -55,6 +63,10 @@ export function downloadFile (options: {
request.write(body)
request.end()
+
+ setTimeout(() => {
+ request.destroy(new Error('Global request timeout'))
+ }, 2 * 3600 * 1000) // 2 hours
})
}