Spaces:
Build error
Build error
fix: curl failure should return 4xx if specified explicitly
Browse files- src/api/crawler.ts +14 -5
src/api/crawler.ts
CHANGED
|
@@ -739,11 +739,20 @@ export class CrawlerHost extends RPCHost {
|
|
| 739 |
// deprecated name
|
| 740 |
crawlOpts?.engine === 'direct'
|
| 741 |
) {
|
| 742 |
-
|
| 743 |
-
|
| 744 |
-
|
| 745 |
-
|
| 746 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 747 |
}
|
| 748 |
const draftSnapshot = await this.snapshotFormatter.createSnapshotFromFile(urlToCrawl, sideLoaded.file, sideLoaded.contentType, sideLoaded.fileName);
|
| 749 |
yield this.jsdomControl.narrowSnapshot(draftSnapshot, crawlOpts);
|
|
|
|
| 739 |
// deprecated name
|
| 740 |
crawlOpts?.engine === 'direct'
|
| 741 |
) {
|
| 742 |
+
let sideLoaded;
|
| 743 |
+
try {
|
| 744 |
+
sideLoaded = (crawlOpts?.allocProxy && !crawlOpts?.proxyUrl) ?
|
| 745 |
+
await this.sideLoadWithAllocatedProxy(urlToCrawl, crawlOpts) :
|
| 746 |
+
await this.curlControl.sideLoad(urlToCrawl, crawlOpts);
|
| 747 |
+
|
| 748 |
+
} catch (err) {
|
| 749 |
+
if (err instanceof ServiceBadAttemptError) {
|
| 750 |
+
throw new AssertionFailureError(err.message);
|
| 751 |
+
}
|
| 752 |
+
throw err;
|
| 753 |
+
}
|
| 754 |
+
if (!sideLoaded?.file) {
|
| 755 |
+
throw new AssertionFailureError(`Remote server did not return a body: ${urlToCrawl}`);
|
| 756 |
}
|
| 757 |
const draftSnapshot = await this.snapshotFormatter.createSnapshotFromFile(urlToCrawl, sideLoaded.file, sideLoaded.contentType, sideLoaded.fileName);
|
| 758 |
yield this.jsdomControl.narrowSnapshot(draftSnapshot, crawlOpts);
|