Skip to content

Commit e707b60

Browse files
authored
fix: run data cleanup (#13)
* fix: clean resulting data * feat: remove run data and return with helper
1 parent 9cf4341 commit e707b60

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

nodes/ApifyContentCrawler/__tests__/Apify.node.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ describe('Apify Node', () => {
8383
const data = getTaskData(nodeResult);
8484
expect(typeof data).toBe('object');
8585

86-
const first = data?.['0'] as { json: any };
87-
expect(first.json).toEqual(mockResultDataset[0]);
86+
expect(data).toEqual(mockResultDataset[0]);
8887

8988
console.log(`Pending mocks for ${workflowJsonName}:`, scope.pendingMocks());
9089
expect(scope.isDone()).toBe(true);

nodes/ApifyContentCrawler/resources/executeActor.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { IExecuteFunctions, INodeExecutionData, NodeApiError } from 'n8n-workflow';
2-
import { apiRequest, getResults, isUsedAsAiTool, pollRunStatus } from './genericFunctions';
2+
import { apiRequest, getResults, pollRunStatus } from './genericFunctions';
33

44
export async function getDefaultBuild(this: IExecuteFunctions, actorId: string) {
55
const defaultBuildResp = await apiRequest.call(this, {
@@ -61,12 +61,9 @@ export async function executeActorRunFlow(
6161

6262
const runId = run.data.id;
6363
const datasetId = run.data.defaultDatasetId;
64-
const lastRunData = await pollRunStatus.call(this, runId);
65-
const resultData = await getResults.call(this, datasetId);
6664

67-
if (isUsedAsAiTool(this.getNode().type)) {
68-
return { json: { ...resultData } };
69-
}
65+
// Wait for Actor run to finish
66+
await pollRunStatus.call(this, runId);
7067

71-
return { json: { ...lastRunData, ...resultData } };
68+
return await getResults.call(this, datasetId);
7269
}

0 commit comments

Comments
 (0)