Warn about unset prefetchTimeout, default to 5000 ms
This commit is contained in:
parent
b2a363f099
commit
ff886846a8
@ -10,6 +10,8 @@ const storage = require("../storage");
|
|||||||
const currentFetchPromises = new Map();
|
const currentFetchPromises = new Map();
|
||||||
const imageTypeRegex = /^image\/.+/;
|
const imageTypeRegex = /^image\/.+/;
|
||||||
const mediaTypeRegex = /^(audio|video)\/.+/;
|
const mediaTypeRegex = /^(audio|video)\/.+/;
|
||||||
|
const log = require("../../log");
|
||||||
|
|
||||||
|
|
||||||
module.exports = function (client, chan, msg, cleanText) {
|
module.exports = function (client, chan, msg, cleanText) {
|
||||||
if (!Helper.config.prefetch) {
|
if (!Helper.config.prefetch) {
|
||||||
@ -381,6 +383,12 @@ function fetch(uri, headers) {
|
|||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const prefetchTimeout = Helper.config.prefetchTimeout;
|
||||||
|
|
||||||
|
if (!prefetchTimeout) {
|
||||||
|
log.warn("prefetchTimeout is missing from your The Lounge configuration, defaulting to 5000 ms");
|
||||||
|
}
|
||||||
|
|
||||||
promise = new Promise((resolve, reject) => {
|
promise = new Promise((resolve, reject) => {
|
||||||
let buffer = Buffer.from("");
|
let buffer = Buffer.from("");
|
||||||
let contentLength = 0;
|
let contentLength = 0;
|
||||||
@ -390,7 +398,7 @@ function fetch(uri, headers) {
|
|||||||
try {
|
try {
|
||||||
const gotStream = got.stream(uri, {
|
const gotStream = got.stream(uri, {
|
||||||
retry: 0,
|
retry: 0,
|
||||||
timeout: Helper.config.prefetchTimeout, // milliseconds
|
timeout: prefetchTimeout || 5000, // milliseconds
|
||||||
headers: getRequestHeaders(headers),
|
headers: getRequestHeaders(headers),
|
||||||
https: {
|
https: {
|
||||||
rejectUnauthorized: false,
|
rejectUnauthorized: false,
|
||||||
|
Loading…
Reference in New Issue
Block a user