Skip to content

Commit a63d2a2

Browse files
committed
fixes
1 parent 17288f5 commit a63d2a2

File tree

7 files changed

+103
-133
lines changed

7 files changed

+103
-133
lines changed

docs/docs/botasaurus-desktop/botasaurus-desktop-api/adding-domain-and-ssl.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,18 @@ The process involves two main steps:
4343

4444
I recommend these registrars:
4545

46-
- **Cloudflare Domains** - Cheapest option (offers at-cost pricing, charging only the ICANN registry fees with no markup)
46+
- **Cloudflare Domains** - Cheapest option (offers at-cost pricing, charging only the ICANN registry fees with no markup)
4747
- **Porkbun** - Second cheapest option
48-
- **Namecheap**
4948

50-
Avoid GoDaddy. While their initial registration costs are low, renewal prices are significantly higher than Porkbun and Namecheap, costing more in the long run.
49+
Avoid GoDaddy and Namecheap.
50+
- Although their initial registration costs are low, their renewal prices are significantly higher than Porkbun and Cloudflare Domains. Therefore, it is unwise to buy from them.
51+
- Also, do not even search for a domain on GoDaddy. They may purchase the domain themselves and then offer it to you at a much higher price.
5152

52-
I personally use Porkbun because it offers auto-renewals and sends multiple renewal reminders (45 days and 30 days before expiry), so I don't forget to renew my domains.
53+
I personally use Porkbun because it offers automatic renewals 45 days before expiry and sends multiple renewal reminders (45 days and 30 days before expiry), so I don't forget to renew my domains.
5354

5455
![Porkbun Renewal Emails](https://raw.githubusercontent.com/omkarcloud/botasaurus/master/images/domains/porkbun-renewal-emails.png)
5556

56-
Also, Porkbun's logo and branding are funny, nevertheless they provide a good experience and are [highly ratings on Trustpilot.](https://www.trustpilot.com/review/porkbun.com)
57+
Also, Porkbun's logo and branding are funny, nevertheless they provide a good experience and are [highly rated on Trustpilot.](https://www.trustpilot.com/review/porkbun.com)
5758

5859
2. Next, log in to your domain registrar and create DNS **A records** pointing to your VM's IP address.
5960

js/botasaurus-server-js/src/ndjson.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export class NDJSONWriteStream {
4141
}
4242

4343
end(): Promise<void> {
44+
if (!this.writeStream){
45+
return Promise.resolve()
46+
}
4447
return new Promise(async (resolve) => {
4548
await this.preEnd()
4649
this.writeStream.end(() => {

js/botasaurus-server-js/src/routes-db-logic.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,8 +1003,8 @@ function convertUnicodeDictToAsciiDictInPlace(inputList: any[]): any[] {
10031003
if (abortedChildrenCount === allChildrenCount) {
10041004
await TaskHelper.abortTask(parentId);
10051005
} else {
1006-
const failedChildrenCount = await TaskHelper.getFailedChildrenCount(parentId, taskId);
1007-
if (failedChildrenCount) {
1006+
const hasFailedChildrenCount = await TaskHelper.hasFailedChildren(parentId, taskId);
1007+
if (hasFailedChildrenCount) {
10081008
fn = async () => {
10091009
await TaskHelper.collectAndSaveAllTask(
10101010
parentId,
@@ -1046,14 +1046,14 @@ function convertUnicodeDictToAsciiDictInPlace(inputList: any[]): any[] {
10461046
// Only abort tasks that are in PENDING or IN_PROGRESS status
10471047
const abortableStatuses: string[] = [TaskStatus.PENDING, TaskStatus.IN_PROGRESS];
10481048
if (!abortableStatuses.includes(status)) {
1049-
return;
1049+
// return;
10501050
}
10511051

10521052
let fn: (() => Promise<void>) | null = null;
10531053

10541054
if (is_all_task) {
10551055
await TaskHelper.abortChildTasks(taskId);
1056-
await TaskHelper.collectAndSaveAllTaskForAbortedTask(taskId, removeDuplicatesBy);
1056+
await TaskHelper.collectAndSaveAllTask(taskId, null, removeDuplicatesBy, TaskStatus.ABORTED, false);
10571057
} else {
10581058
if (parentId) {
10591059
const allChildrenCount = await TaskHelper.getAllChildrenCount(parentId, taskId);
@@ -1075,8 +1075,8 @@ function convertUnicodeDictToAsciiDictInPlace(inputList: any[]): any[] {
10751075
if (abortedChildrenCount === allChildrenCount) {
10761076
await TaskHelper.abortTask(parentId);
10771077
} else {
1078-
const failedChildrenCount = await TaskHelper.getFailedChildrenCount(parentId, taskId);
1079-
if (failedChildrenCount) {
1078+
const hasFailedChildrenCount = await TaskHelper.hasFailedChildren(parentId, taskId);
1079+
if (hasFailedChildrenCount) {
10801080
fn = async () => {
10811081
await TaskHelper.collectAndSaveAllTask(
10821082
parentId,

js/botasaurus-server-js/src/server.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { BaseSort, Sort } from './sorts';
22
import { ScraperType } from './scraper-type';
3-
import { isObject } from './utils';
3+
import { isNoentError, isObject } from './utils';
44
import { _hash } from 'botasaurus/cache';
55
import * as fs from 'fs';
66
import { isNotNullish } from './null-utils'
@@ -24,8 +24,7 @@ function getReadme(): string {
2424
const text = fs.readFileSync(readmeFile, 'utf-8');
2525
return text;
2626
} catch (error) {
27-
// @ts-ignore
28-
if (error.code === 'ENOENT') {
27+
if (isNoentError(error)) {
2928
return '';
3029
}
3130
throw error;

js/botasaurus-server-js/src/task-executor.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ class TaskExecutor {
154154
if (isAllChildTasksDone) {
155155
const is_large: any = parentTask.is_large
156156

157-
const failedChildrenCount = await TaskHelper.getFailedChildrenCount(parentId)
158-
const status = failedChildrenCount ? TaskStatus.FAILED : TaskStatus.COMPLETED
157+
const hasFailedChildrenCount = await TaskHelper.hasFailedChildren(parentId)
158+
const status = hasFailedChildrenCount ? TaskStatus.FAILED : TaskStatus.COMPLETED
159159

160160
const removeDuplicatesBy = Server.getRemoveDuplicatesBy(parentTask.scraper_name)
161161
// Find the oldest started_at task that is the parent of the current task
@@ -644,13 +644,12 @@ class TaskExecutor {
644644
) {
645645
const parentTask = await TaskHelper.getTask(
646646
parentId,
647-
[TaskStatus.PENDING, TaskStatus.IN_PROGRESS],
648647
)
649648

650649
if (parentTask) {
651650
const is_large: any = parentTask.is_large
652651
await TaskHelper.updateParentTaskResults(parentId, result, is_large)
653-
await this.finalizeParentIfAllChildrenDone(parentId, removeDuplicatesBy, is_large)
652+
await this.finalizeParentIfAllChildrenDone(parentId, parentTask, removeDuplicatesBy, is_large)
654653
}
655654
}
656655

@@ -664,13 +663,12 @@ class TaskExecutor {
664663
) {
665664
const parentTask = await TaskHelper.getTask(
666665
parentId,
667-
[TaskStatus.PENDING, TaskStatus.IN_PROGRESS],
668666
)
669667

670668
if (parentTask) {
671669
const is_large: any = parentTask.is_large
672670
await TaskHelper.streamChildToParentResults(childId, parentId, is_large)
673-
await this.finalizeParentIfAllChildrenDone(parentId, removeDuplicatesBy, is_large)
671+
await this.finalizeParentIfAllChildrenDone(parentId, parentTask, removeDuplicatesBy, is_large)
674672
}
675673
}
676674

@@ -679,13 +677,13 @@ class TaskExecutor {
679677
*/
680678
private async finalizeParentIfAllChildrenDone(
681679
parentId: number,
680+
parentTask: Task,
682681
removeDuplicatesBy: string | null,
683682
is_large: boolean
684683
) {
685684
const isAllChildTasksDone = await TaskHelper.areAllChildTaskDone(parentId)
686685
if (isAllChildTasksDone) {
687-
const failedChildrenCount = await TaskHelper.getFailedChildrenCount(parentId)
688-
const status = failedChildrenCount ? TaskStatus.FAILED : TaskStatus.COMPLETED
686+
const status = await this.getParentFinalizingStatus(parentId, parentTask)
689687
await TaskHelper.readCleanSaveTask(
690688
parentId,
691689
removeDuplicatesBy,
@@ -695,16 +693,24 @@ class TaskExecutor {
695693
}
696694
}
697695

696+
private async getParentFinalizingStatus(parentId: number, parentTask: Task) {
697+
if (parentTask.status === TaskStatus.ABORTED) {
698+
return TaskStatus.ABORTED
699+
}
700+
const hasFailedChildrenCount = await TaskHelper.hasFailedChildren(parentId)
701+
return hasFailedChildrenCount ? TaskStatus.FAILED : TaskStatus.COMPLETED
702+
}
703+
698704
async completeAsMuchAllTaskAsPossible(
699705
parentId: number,
700706
removeDuplicatesBy: string | null
701707
): Promise<void> {
702708
const isAllChildTasksDone = await TaskHelper.areAllChildTaskDone(parentId)
703709
if (isAllChildTasksDone) {
704-
const failedChildrenCount = await TaskHelper.getFailedChildrenCount(
710+
const hasFailedChildrenCount = await TaskHelper.hasFailedChildren(
705711
parentId
706712
)
707-
const status = failedChildrenCount
713+
const status = hasFailedChildrenCount
708714
? TaskStatus.FAILED
709715
: TaskStatus.COMPLETED
710716
await TaskHelper.collectAndSaveAllTask(

0 commit comments

Comments
 (0)