Spaces:
Build error
Build error
fix: timeout parameter
Browse files
backend/functions/src/cloud-functions/crawler.ts
CHANGED
|
@@ -710,7 +710,7 @@ ${suffixMixins.length ? `\n${suffixMixins.join('\n\n')}\n` : ''}`;
|
|
| 710 |
const formatted = await this.formatSnapshot(crawlerOptions.respondWith, scrapped, urlToCrawl);
|
| 711 |
chargeAmount = this.getChargeAmount(formatted);
|
| 712 |
|
| 713 |
-
if (crawlerOptions.timeout
|
| 714 |
return formatted;
|
| 715 |
}
|
| 716 |
}
|
|
@@ -734,7 +734,7 @@ ${suffixMixins.length ? `\n${suffixMixins.join('\n\n')}\n` : ''}`;
|
|
| 734 |
const formatted = await this.formatSnapshot(crawlerOptions.respondWith, scrapped, urlToCrawl);
|
| 735 |
chargeAmount = this.getChargeAmount(formatted);
|
| 736 |
|
| 737 |
-
if (crawlerOptions.timeout
|
| 738 |
if (crawlerOptions.respondWith === 'screenshot' && Reflect.get(formatted, 'screenshotUrl')) {
|
| 739 |
|
| 740 |
return assignTransferProtocolMeta(`${formatted}`,
|
|
|
|
| 710 |
const formatted = await this.formatSnapshot(crawlerOptions.respondWith, scrapped, urlToCrawl);
|
| 711 |
chargeAmount = this.getChargeAmount(formatted);
|
| 712 |
|
| 713 |
+
if (crawlerOptions.timeout === undefined) {
|
| 714 |
return formatted;
|
| 715 |
}
|
| 716 |
}
|
|
|
|
| 734 |
const formatted = await this.formatSnapshot(crawlerOptions.respondWith, scrapped, urlToCrawl);
|
| 735 |
chargeAmount = this.getChargeAmount(formatted);
|
| 736 |
|
| 737 |
+
if (crawlerOptions.timeout === undefined) {
|
| 738 |
if (crawlerOptions.respondWith === 'screenshot' && Reflect.get(formatted, 'screenshotUrl')) {
|
| 739 |
|
| 740 |
return assignTransferProtocolMeta(`${formatted}`,
|
backend/functions/src/dto/scrapping-options.ts
CHANGED
|
@@ -213,8 +213,8 @@ export class CrawlerOptions extends AutoCastable {
|
|
| 213 |
}
|
| 214 |
|
| 215 |
let timeoutSeconds = parseInt(ctx?.req.get('x-timeout') || '');
|
| 216 |
-
if (!isNaN(timeoutSeconds) && timeoutSeconds > 0
|
| 217 |
-
instance.timeout = timeoutSeconds;
|
| 218 |
} else if (ctx?.req.get('x-timeout')) {
|
| 219 |
instance.timeout = null;
|
| 220 |
}
|
|
|
|
| 213 |
}
|
| 214 |
|
| 215 |
let timeoutSeconds = parseInt(ctx?.req.get('x-timeout') || '');
|
| 216 |
+
if (!isNaN(timeoutSeconds) && timeoutSeconds > 0) {
|
| 217 |
+
instance.timeout = timeoutSeconds <= 180 ? timeoutSeconds : 180;
|
| 218 |
} else if (ctx?.req.get('x-timeout')) {
|
| 219 |
instance.timeout = null;
|
| 220 |
}
|