@devrev/ts-adaas 1.19.9-beta.0 → 1.19.9-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/attachments-streaming/attachments-streaming-pool.d.ts.map +1 -1
- package/dist/attachments-streaming/attachments-streaming-pool.js +6 -4
- package/dist/attachments-streaming/attachments-streaming-pool.test.js +65 -0
- package/dist/http/axios-client-internal.d.ts.map +1 -1
- package/dist/http/axios-client-internal.js +1 -19
- package/dist/mock-server/mock-server.d.ts +0 -4
- package/dist/mock-server/mock-server.d.ts.map +1 -1
- package/dist/mock-server/mock-server.interfaces.d.ts +4 -9
- package/dist/mock-server/mock-server.interfaces.d.ts.map +1 -1
- package/dist/mock-server/mock-server.js +18 -30
- package/dist/multithreading/spawn/spawn.d.ts +1 -1
- package/dist/multithreading/spawn/spawn.d.ts.map +1 -1
- package/dist/multithreading/spawn/spawn.js +6 -11
- package/dist/multithreading/spawn/spawn.test.js +0 -1
- package/dist/multithreading/worker-adapter/worker-adapter.artifacts.test.js +1 -1
- package/dist/multithreading/worker-adapter/worker-adapter.d.ts +5 -10
- package/dist/multithreading/worker-adapter/worker-adapter.d.ts.map +1 -1
- package/dist/multithreading/worker-adapter/worker-adapter.emit.test.js +9 -15
- package/dist/multithreading/worker-adapter/worker-adapter.extraction.test.js +1 -1
- package/dist/multithreading/worker-adapter/worker-adapter.helpers.d.ts +1 -0
- package/dist/multithreading/worker-adapter/worker-adapter.helpers.d.ts.map +1 -1
- package/dist/multithreading/worker-adapter/worker-adapter.helpers.js +7 -0
- package/dist/multithreading/worker-adapter/worker-adapter.js +82 -92
- package/dist/repo/repo.d.ts +2 -1
- package/dist/repo/repo.d.ts.map +1 -1
- package/dist/repo/repo.helpers.d.ts +6 -0
- package/dist/repo/repo.helpers.d.ts.map +1 -0
- package/dist/repo/repo.helpers.js +16 -0
- package/dist/repo/repo.js +16 -21
- package/dist/repo/repo.test.js +1 -32
- package/dist/types/extraction.d.ts.map +1 -1
- package/dist/types/workers.d.ts +0 -4
- package/dist/types/workers.d.ts.map +1 -1
- package/dist/uploader/uploader.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/multithreading/worker-adapter/worker-adapter.upload-failure.test.d.ts +0 -2
- package/dist/multithreading/worker-adapter/worker-adapter.upload-failure.test.d.ts.map +0 -1
- package/dist/multithreading/worker-adapter/worker-adapter.upload-failure.test.js +0 -135
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachments-streaming-pool.d.ts","sourceRoot":"","sources":["../../src/attachments-streaming/attachments-streaming-pool.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAEzF,qBAAa,wBAAwB,CAAC,cAAc;IAClD,OAAO,CAAC,OAAO,CAAgC;IAC/C,OAAO,CAAC,WAAW,CAAyB;IAC5C,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,MAAM,CAA4C;IAE1D,OAAO,CAAC,mBAAmB,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAM;gBAEnC,EACV,OAAO,EACP,WAAW,EACX,SAAc,EACd,MAAM,GACP,EAAE,8BAA8B,CAAC,cAAc,CAAC;YAQnC,cAAc;IAS5B;;;;;OAKG;IAEH,OAAO,CAAC,2BAA2B;IAsB7B,SAAS,IAAI,OAAO,CAAC,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"attachments-streaming-pool.d.ts","sourceRoot":"","sources":["../../src/attachments-streaming/attachments-streaming-pool.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAEzF,qBAAa,wBAAwB,CAAC,cAAc;IAClD,OAAO,CAAC,OAAO,CAAgC;IAC/C,OAAO,CAAC,WAAW,CAAyB;IAC5C,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,MAAM,CAA4C;IAE1D,OAAO,CAAC,mBAAmB,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAM;gBAEnC,EACV,OAAO,EACP,WAAW,EACX,SAAc,EACd,MAAM,GACP,EAAE,8BAA8B,CAAC,cAAc,CAAC;YAQnC,cAAc;IAS5B;;;;;OAKG;IAEH,OAAO,CAAC,2BAA2B;IAsB7B,SAAS,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAgDjD,kBAAkB;CA0FzB"}
|
|
@@ -69,8 +69,10 @@ class AttachmentsStreamingPool {
|
|
|
69
69
|
for (let i = 0; i < initialBatchSize; i++) {
|
|
70
70
|
initialPromises.push(this.startPoolStreaming());
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
await Promise.race([
|
|
73
|
+
Promise.all(initialPromises),
|
|
74
|
+
this.adapter.timeoutSignal,
|
|
75
|
+
]);
|
|
74
76
|
if (this.delay) {
|
|
75
77
|
return { delay: this.delay };
|
|
76
78
|
}
|
|
@@ -117,8 +119,8 @@ class AttachmentsStreamingPool {
|
|
|
117
119
|
await this.updateProgress();
|
|
118
120
|
continue;
|
|
119
121
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
if (!this.adapter.isTimeout &&
|
|
123
|
+
((_c = (_b = this.adapter.state.toDevRev) === null || _b === void 0 ? void 0 : _b.attachmentsMetadata) === null || _c === void 0 ? void 0 : _c.lastProcessedAttachmentsIdsList)) {
|
|
122
124
|
(_d = this.adapter.state.toDevRev) === null || _d === void 0 ? void 0 : _d.attachmentsMetadata.lastProcessedAttachmentsIdsList.push({ id: attachment.id, parent_id: attachment.parent_id });
|
|
123
125
|
}
|
|
124
126
|
await this.updateProgress();
|
|
@@ -17,6 +17,10 @@ describe(attachments_streaming_pool_1.AttachmentsStreamingPool.name, () => {
|
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
|
+
isTimeout: false,
|
|
21
|
+
// Never resolves: streamAll's race is decided by the workers completing,
|
|
22
|
+
// unless a test overrides this / flips isTimeout.
|
|
23
|
+
timeoutSignal: new Promise(() => { }),
|
|
20
24
|
processAttachment: jest
|
|
21
25
|
.fn()
|
|
22
26
|
.mockResolvedValue({}),
|
|
@@ -513,4 +517,65 @@ describe(attachments_streaming_pool_1.AttachmentsStreamingPool.name, () => {
|
|
|
513
517
|
expect(mockStreamFn).toHaveBeenCalled();
|
|
514
518
|
});
|
|
515
519
|
});
|
|
520
|
+
describe('soft timeout handling', () => {
|
|
521
|
+
it('should resolve streamAll when the timeout signal fires even if a worker is stuck in flight', async () => {
|
|
522
|
+
// A worker stuck in a never-resolving request: only the timeout race can
|
|
523
|
+
// unblock streamAll.
|
|
524
|
+
mockAdapter.processAttachment.mockImplementation(async () => new Promise(() => { }));
|
|
525
|
+
let fireTimeout;
|
|
526
|
+
mockAdapter.timeoutSignal = new Promise((resolve) => {
|
|
527
|
+
fireTimeout = resolve;
|
|
528
|
+
});
|
|
529
|
+
const pool = new attachments_streaming_pool_1.AttachmentsStreamingPool({
|
|
530
|
+
adapter: mockAdapter,
|
|
531
|
+
attachments: mockAttachments,
|
|
532
|
+
batchSize: 10,
|
|
533
|
+
stream: mockStream,
|
|
534
|
+
});
|
|
535
|
+
const streamAllPromise = pool.streamAll();
|
|
536
|
+
mockAdapter.isTimeout = true;
|
|
537
|
+
fireTimeout();
|
|
538
|
+
const result = await streamAllPromise;
|
|
539
|
+
expect(result).toEqual({});
|
|
540
|
+
});
|
|
541
|
+
it('should not record an attachment as processed when a timeout fires while it is in flight', async () => {
|
|
542
|
+
mockAdapter.processAttachment.mockImplementation(async () => {
|
|
543
|
+
await Promise.resolve();
|
|
544
|
+
mockAdapter.isTimeout = true;
|
|
545
|
+
return {};
|
|
546
|
+
});
|
|
547
|
+
const pool = new attachments_streaming_pool_1.AttachmentsStreamingPool({
|
|
548
|
+
adapter: mockAdapter,
|
|
549
|
+
attachments: mockAttachments,
|
|
550
|
+
batchSize: 1,
|
|
551
|
+
stream: mockStream,
|
|
552
|
+
});
|
|
553
|
+
await pool.streamAll();
|
|
554
|
+
expect(mockAdapter.state.toDevRev.attachmentsMetadata
|
|
555
|
+
.lastProcessedAttachmentsIdsList).toEqual([]);
|
|
556
|
+
expect(mockAdapter.processAttachment).toHaveBeenCalledTimes(1);
|
|
557
|
+
});
|
|
558
|
+
it('should record attachments completed before the timeout and stop after', async () => {
|
|
559
|
+
let calls = 0;
|
|
560
|
+
mockAdapter.processAttachment.mockImplementation(async () => {
|
|
561
|
+
await Promise.resolve();
|
|
562
|
+
calls++;
|
|
563
|
+
if (calls === 2) {
|
|
564
|
+
mockAdapter.isTimeout = true;
|
|
565
|
+
}
|
|
566
|
+
return {};
|
|
567
|
+
});
|
|
568
|
+
const pool = new attachments_streaming_pool_1.AttachmentsStreamingPool({
|
|
569
|
+
adapter: mockAdapter,
|
|
570
|
+
attachments: mockAttachments,
|
|
571
|
+
batchSize: 1,
|
|
572
|
+
stream: mockStream,
|
|
573
|
+
});
|
|
574
|
+
await pool.streamAll();
|
|
575
|
+
expect(mockAdapter.state.toDevRev.attachmentsMetadata
|
|
576
|
+
.lastProcessedAttachmentsIdsList).toEqual([{ id: 'attachment-1', parent_id: 'parent-1' }]);
|
|
577
|
+
// 2nd was started then abandoned; 3rd never started.
|
|
578
|
+
expect(mockAdapter.processAttachment).toHaveBeenCalledTimes(2);
|
|
579
|
+
});
|
|
580
|
+
});
|
|
516
581
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios-client-internal.d.ts","sourceRoot":"","sources":["../../src/http/axios-client-internal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"axios-client-internal.d.ts","sourceRoot":"","sources":["../../src/http/axios-client-internal.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,WAAW,+BAEf,CAAC;AAyFH,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -6,30 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.axiosClient = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const axios_retry_1 = __importDefault(require("axios-retry"));
|
|
9
|
-
const node_worker_threads_1 = require("node:worker_threads");
|
|
10
|
-
/** Production default; tests may lower via workerData.options.httpRetries or ADAAS_TEST_HTTP_RETRIES. */
|
|
11
|
-
function getHttpRetryCount() {
|
|
12
|
-
var _a;
|
|
13
|
-
if (!node_worker_threads_1.isMainThread &&
|
|
14
|
-
((_a = node_worker_threads_1.workerData === null || node_worker_threads_1.workerData === void 0 ? void 0 : node_worker_threads_1.workerData.options) === null || _a === void 0 ? void 0 : _a.httpRetries) !== undefined &&
|
|
15
|
-
node_worker_threads_1.workerData.options.httpRetries >= 0) {
|
|
16
|
-
return node_worker_threads_1.workerData.options.httpRetries;
|
|
17
|
-
}
|
|
18
|
-
const fromEnv = process.env.ADAAS_TEST_HTTP_RETRIES;
|
|
19
|
-
if (fromEnv !== undefined) {
|
|
20
|
-
const parsed = parseInt(fromEnv, 10);
|
|
21
|
-
if (!isNaN(parsed) && parsed >= 0) {
|
|
22
|
-
return parsed;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return 5;
|
|
26
|
-
}
|
|
27
9
|
const axiosClient = axios_1.default.create({
|
|
28
10
|
timeout: 30 * 1000,
|
|
29
11
|
});
|
|
30
12
|
exports.axiosClient = axiosClient;
|
|
31
13
|
(0, axios_retry_1.default)(axiosClient, {
|
|
32
|
-
retries:
|
|
14
|
+
retries: 5,
|
|
33
15
|
shouldResetTimeout: true,
|
|
34
16
|
retryDelay: (retryCount, error) => {
|
|
35
17
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
@@ -31,10 +31,6 @@ export declare class MockServer {
|
|
|
31
31
|
* Also clears request tracking data.
|
|
32
32
|
*/
|
|
33
33
|
resetRoutes(): void;
|
|
34
|
-
/**
|
|
35
|
-
* Returns all POST requests to the platform callback URL.
|
|
36
|
-
*/
|
|
37
|
-
getCallbackRequests(): RequestInfo[];
|
|
38
34
|
/**
|
|
39
35
|
* Returns the most recent request or undefined if no requests exist.
|
|
40
36
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-server.d.ts","sourceRoot":"","sources":["../../src/mock-server/mock-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,WAAW,EACX,WAAW,EAEZ,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"mock-server.d.ts","sourceRoot":"","sources":["../../src/mock-server/mock-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,WAAW,EACX,WAAW,EAEZ,MAAM,0BAA0B,CAAC;AA4ElC;;;;GAIG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,YAAY,CAAS;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,aAAa,CAA4B;IACjD,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,aAAa,CAA4B;gBAErC,IAAI,GAAE,MAAiC;IAMtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAkBpB,aAAa;IA+B3B;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IA6B3B,OAAO,CAAC,WAAW;IAInB;;OAEG;IACI,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IA8E1C;;;OAGG;IACI,WAAW,IAAI,IAAI;IAM1B;;OAEG;IACI,cAAc,IAAI,WAAW,GAAG,SAAS;IAOhD;;OAEG;IACI,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAI5D;;OAEG;IACI,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE;CAQhE"}
|
|
@@ -13,6 +13,8 @@ export interface MockResponse extends ServerResponse {
|
|
|
13
13
|
status(code: number): MockResponse;
|
|
14
14
|
/** Send a JSON response */
|
|
15
15
|
json(data: unknown): void;
|
|
16
|
+
/** Send a raw binary (Buffer) response */
|
|
17
|
+
buffer(data: Buffer): void;
|
|
16
18
|
/** Send an empty response */
|
|
17
19
|
send(): void;
|
|
18
20
|
}
|
|
@@ -43,19 +45,12 @@ export interface RouteConfig {
|
|
|
43
45
|
status: number;
|
|
44
46
|
/** Optional response body to send as JSON */
|
|
45
47
|
body?: unknown;
|
|
48
|
+
/** Optional raw binary response body, e.g. gzipped JSONL (takes precedence over `body`) */
|
|
49
|
+
bodyBuffer?: Buffer;
|
|
46
50
|
/** Optional headers to send with the response */
|
|
47
51
|
headers?: Record<string, string>;
|
|
48
52
|
/** Optional retry configuration for simulating failures before success */
|
|
49
53
|
retry?: RetryConfig;
|
|
50
|
-
/**
|
|
51
|
-
* Respond successfully for the first N requests, then return an error.
|
|
52
|
-
* Useful for partial-upload scenarios (first batch succeeds, second fails).
|
|
53
|
-
*/
|
|
54
|
-
succeedThenFail?: {
|
|
55
|
-
successCount: number;
|
|
56
|
-
errorStatus?: number;
|
|
57
|
-
errorBody?: unknown;
|
|
58
|
-
};
|
|
59
54
|
/** Optional delay in milliseconds before sending the response */
|
|
60
55
|
delay?: number;
|
|
61
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-server.interfaces.d.ts","sourceRoot":"","sources":["../../src/mock-server/mock-server.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAEvD,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C,MAAM,WAAW,aAAc,SAAQ,eAAe;IACpD,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,YAAa,SAAQ,cAAc;IAClD,yCAAyC;IACzC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,CAAC;IACnD,+BAA+B;IAC/B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAAC;IACnC,2BAA2B;IAC3B,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,6BAA6B;IAC7B,IAAI,IAAI,IAAI,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,qEAAqE;IACrE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB
|
|
1
|
+
{"version":3,"file":"mock-server.interfaces.d.ts","sourceRoot":"","sources":["../../src/mock-server/mock-server.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,c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AAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,oDAAoD;IACpD,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
|
|
@@ -56,6 +56,10 @@ function wrapResponse(res) {
|
|
|
56
56
|
res.writeHead(statusCode, { 'Content-Type': 'application/json' });
|
|
57
57
|
res.end(JSON.stringify(data));
|
|
58
58
|
};
|
|
59
|
+
mock.buffer = (data) => {
|
|
60
|
+
res.writeHead(statusCode, { 'Content-Type': 'application/octet-stream' });
|
|
61
|
+
res.end(data);
|
|
62
|
+
};
|
|
59
63
|
mock.send = () => {
|
|
60
64
|
res.writeHead(statusCode);
|
|
61
65
|
res.end();
|
|
@@ -174,35 +178,19 @@ class MockServer {
|
|
|
174
178
|
* Configures a route to return a specific status code and optional response body.
|
|
175
179
|
*/
|
|
176
180
|
setRoute(config) {
|
|
177
|
-
const { path, method, status, body,
|
|
181
|
+
const { path, method, status, body, bodyBuffer, retry, headers, delay } = config;
|
|
178
182
|
const key = this.getRouteKey(method, path);
|
|
179
|
-
if (retry
|
|
183
|
+
if (retry) {
|
|
180
184
|
this.requestCounts.set(key, 0);
|
|
181
185
|
}
|
|
182
186
|
this.routeHandlers.set(key, (req, res) => {
|
|
183
187
|
const sendResponse = (responseDelay) => {
|
|
184
188
|
const send = () => {
|
|
185
|
-
var _a, _b
|
|
186
|
-
if (
|
|
187
|
-
const currentCount = this.requestCounts.get(key) || 0;
|
|
188
|
-
this.requestCounts.set(key, currentCount + 1);
|
|
189
|
-
if (currentCount < succeedThenFail.successCount) {
|
|
190
|
-
this.defaultRouteHandler(req, res);
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
const errorStatus = (_a = succeedThenFail.errorStatus) !== null && _a !== void 0 ? _a : 400;
|
|
194
|
-
if (succeedThenFail.errorBody !== undefined) {
|
|
195
|
-
res.status(errorStatus).json(succeedThenFail.errorBody);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
res.status(errorStatus).send();
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
else if (retry) {
|
|
189
|
+
var _a, _b;
|
|
190
|
+
if (retry) {
|
|
203
191
|
const currentCount = this.requestCounts.get(key) || 0;
|
|
204
|
-
const failureCount = (
|
|
205
|
-
const errorStatus = (
|
|
192
|
+
const failureCount = (_a = retry.failureCount) !== null && _a !== void 0 ? _a : 4;
|
|
193
|
+
const errorStatus = (_b = retry.errorStatus) !== null && _b !== void 0 ? _b : 500;
|
|
206
194
|
if (currentCount < failureCount) {
|
|
207
195
|
this.requestCounts.set(key, currentCount + 1);
|
|
208
196
|
const sendFailure = () => {
|
|
@@ -228,7 +216,10 @@ class MockServer {
|
|
|
228
216
|
if (headers) {
|
|
229
217
|
res.set(headers);
|
|
230
218
|
}
|
|
231
|
-
if (
|
|
219
|
+
if (bodyBuffer !== undefined) {
|
|
220
|
+
res.status(status).buffer(bodyBuffer);
|
|
221
|
+
}
|
|
222
|
+
else if (body !== undefined) {
|
|
232
223
|
res.status(status).json(body);
|
|
233
224
|
}
|
|
234
225
|
else {
|
|
@@ -240,7 +231,10 @@ class MockServer {
|
|
|
240
231
|
if (headers) {
|
|
241
232
|
res.set(headers);
|
|
242
233
|
}
|
|
243
|
-
if (
|
|
234
|
+
if (bodyBuffer !== undefined) {
|
|
235
|
+
res.status(status).buffer(bodyBuffer);
|
|
236
|
+
}
|
|
237
|
+
else if (body !== undefined) {
|
|
244
238
|
res.status(status).json(body);
|
|
245
239
|
}
|
|
246
240
|
else {
|
|
@@ -267,12 +261,6 @@ class MockServer {
|
|
|
267
261
|
this.requestCounts.clear();
|
|
268
262
|
this.requests = [];
|
|
269
263
|
}
|
|
270
|
-
/**
|
|
271
|
-
* Returns all POST requests to the platform callback URL.
|
|
272
|
-
*/
|
|
273
|
-
getCallbackRequests() {
|
|
274
|
-
return this.requests.filter((req) => req.method.toUpperCase() === 'POST' && req.url.includes('callback_url'));
|
|
275
|
-
}
|
|
276
264
|
/**
|
|
277
265
|
* Returns the most recent request or undefined if no requests exist.
|
|
278
266
|
*/
|
|
@@ -25,7 +25,7 @@ export declare class Spawn {
|
|
|
25
25
|
private originalConsole;
|
|
26
26
|
private logger;
|
|
27
27
|
private workerFailedMessage;
|
|
28
|
-
constructor({ event, worker, options, resolve, originalConsole,
|
|
28
|
+
constructor({ event, worker, options, resolve, originalConsole, }: SpawnInterface);
|
|
29
29
|
private clearTimeouts;
|
|
30
30
|
private exitFromMainThread;
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../../src/multithreading/spawn/spawn.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../../src/multithreading/spawn/spawn.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,qBAAqB,EACrB,cAAc,EAGf,MAAM,qBAAqB,CAAC;AA+C7B;;;;;;;;;;;GAWG;AACH,wBAAsB,KAAK,CAAC,cAAc,EAAE,EAC1C,KAAK,EACL,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,OAAO,EACP,cAAc,GACf,EAAE,qBAAqB,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAwFvD;AAED,qBAAa,KAAK;IAChB,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,oBAAoB,CAAkC;IAC9D,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAA4C;IACpE,OAAO,CAAC,gBAAgB,CAA4C;IACpE,OAAO,CAAC,wBAAwB,CAA6C;IAC7E,OAAO,CAAC,OAAO,CAA4C;IAC3D,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,mBAAmB,CAAqB;gBACpC,EACV,KAAK,EACL,MAAM,EACN,OAAO,EACP,OAAO,EACP,eAAe,GAChB,EAAE,cAAc;IAiHjB,OAAO,CAAC,aAAa;YAYP,kBAAkB;CAoCjC"}
|
|
@@ -68,9 +68,8 @@ async function spawn({ event, initialState, workerPath, initialDomainMapping, op
|
|
|
68
68
|
options = Object.assign(Object.assign({}, (options || {})), { isLocalDevelopment: true });
|
|
69
69
|
}
|
|
70
70
|
const originalConsole = console;
|
|
71
|
-
const logger = new logger_1.Logger({ event, options });
|
|
72
71
|
// eslint-disable-next-line no-global-assign
|
|
73
|
-
console =
|
|
72
|
+
console = new logger_1.Logger({ event, options });
|
|
74
73
|
if (translatedEventType !== originalEventType) {
|
|
75
74
|
console.log(`Event type translated from ${originalEventType} to ${translatedEventType}.`);
|
|
76
75
|
}
|
|
@@ -111,7 +110,6 @@ async function spawn({ event, initialState, workerPath, initialDomainMapping, op
|
|
|
111
110
|
options,
|
|
112
111
|
resolve,
|
|
113
112
|
originalConsole,
|
|
114
|
-
logger,
|
|
115
113
|
});
|
|
116
114
|
});
|
|
117
115
|
}
|
|
@@ -134,11 +132,10 @@ async function spawn({ event, initialState, workerPath, initialDomainMapping, op
|
|
|
134
132
|
}
|
|
135
133
|
}
|
|
136
134
|
class Spawn {
|
|
137
|
-
constructor({ event, worker, options, resolve, originalConsole,
|
|
135
|
+
constructor({ event, worker, options, resolve, originalConsole, }) {
|
|
138
136
|
this.defaultLambdaTimeout = constants_1.DEFAULT_LAMBDA_TIMEOUT;
|
|
139
137
|
this.originalConsole = originalConsole || console;
|
|
140
|
-
this.logger =
|
|
141
|
-
logger !== null && logger !== void 0 ? logger : console;
|
|
138
|
+
this.logger = console;
|
|
142
139
|
this.alreadyEmitted = false;
|
|
143
140
|
this.softTimeoutSent = false;
|
|
144
141
|
this.event = event;
|
|
@@ -192,7 +189,7 @@ class Spawn {
|
|
|
192
189
|
}
|
|
193
190
|
});
|
|
194
191
|
worker.on(workers_1.WorkerEvent.WorkerMessage, (message) => {
|
|
195
|
-
var _a, _b, _c, _d, _e
|
|
192
|
+
var _a, _b, _c, _d, _e;
|
|
196
193
|
// Since logs from the worker thread are handled differently in snap-in
|
|
197
194
|
// platform, we need to catch the log messages from worker thread and log
|
|
198
195
|
// them in main thread.
|
|
@@ -200,9 +197,7 @@ class Spawn {
|
|
|
200
197
|
const stringifiedArgs = (_a = message.payload) === null || _a === void 0 ? void 0 : _a.stringifiedArgs;
|
|
201
198
|
const level = (_b = message.payload) === null || _b === void 0 ? void 0 : _b.level;
|
|
202
199
|
const isSdkLog = (_d = (_c = message.payload) === null || _c === void 0 ? void 0 : _c.isSdkLog) !== null && _d !== void 0 ? _d : true;
|
|
203
|
-
|
|
204
|
-
this.logger.logFn(stringifiedArgs, level, isSdkLog);
|
|
205
|
-
}
|
|
200
|
+
this.logger.logFn(stringifiedArgs, level, isSdkLog);
|
|
206
201
|
}
|
|
207
202
|
// If worker sends a message that it has emitted an event, then set alreadyEmitted to true.
|
|
208
203
|
if ((message === null || message === void 0 ? void 0 : message.subject) === workers_1.WorkerMessageSubject.WorkerMessageEmitted) {
|
|
@@ -211,7 +206,7 @@ class Spawn {
|
|
|
211
206
|
}
|
|
212
207
|
// If worker sends a failure message before exiting, capture it for use in the error event.
|
|
213
208
|
if ((message === null || message === void 0 ? void 0 : message.subject) === workers_1.WorkerMessageSubject.WorkerMessageFailed) {
|
|
214
|
-
this.workerFailedMessage = (
|
|
209
|
+
this.workerFailedMessage = (_e = message.payload) === null || _e === void 0 ? void 0 : _e.message;
|
|
215
210
|
}
|
|
216
211
|
});
|
|
217
212
|
// Log memory usage every 30 seconds
|
|
@@ -78,7 +78,6 @@ function buildSpawn(overrides) {
|
|
|
78
78
|
options: overrides.options,
|
|
79
79
|
resolve: (_a = overrides.resolve) !== null && _a !== void 0 ? _a : jest.fn(),
|
|
80
80
|
originalConsole: originalConsole,
|
|
81
|
-
logger: mockLogger,
|
|
82
81
|
});
|
|
83
82
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
83
|
global.console = originalConsole;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const constants_1 = require("../../common/constants");
|
|
4
|
-
const test_utils_1 = require("../../common/test-utils");
|
|
5
4
|
const state_1 = require("../../state/state");
|
|
6
5
|
const jest_setup_1 = require("../../tests/jest.setup");
|
|
7
6
|
const test_helpers_1 = require("../../tests/test-helpers");
|
|
7
|
+
const test_utils_1 = require("../../common/test-utils");
|
|
8
8
|
const types_1 = require("../../types");
|
|
9
9
|
const worker_adapter_1 = require("./worker-adapter");
|
|
10
10
|
// 1. Create a mock function for the method you want to override.
|
|
@@ -25,8 +25,10 @@ export declare function createWorkerAdapter<ConnectorState>({ event, adapterStat
|
|
|
25
25
|
export declare class WorkerAdapter<ConnectorState> {
|
|
26
26
|
readonly event: AirdropEvent;
|
|
27
27
|
readonly options?: WorkerAdapterOptions;
|
|
28
|
-
isTimeout: boolean;
|
|
29
28
|
hasWorkerEmitted: boolean;
|
|
29
|
+
private _isTimeout;
|
|
30
|
+
private resolveTimeoutSignal;
|
|
31
|
+
readonly timeoutSignal: Promise<void>;
|
|
30
32
|
private adapterState;
|
|
31
33
|
private _artifacts;
|
|
32
34
|
private repos;
|
|
@@ -37,6 +39,8 @@ export declare class WorkerAdapter<ConnectorState> {
|
|
|
37
39
|
private _mappers;
|
|
38
40
|
private uploader;
|
|
39
41
|
constructor({ event, adapterState, options, }: WorkerAdapterInterface<ConnectorState>);
|
|
42
|
+
get isTimeout(): boolean;
|
|
43
|
+
set isTimeout(value: boolean);
|
|
40
44
|
get state(): AdapterState<ConnectorState>;
|
|
41
45
|
set state(value: AdapterState<ConnectorState>);
|
|
42
46
|
get reports(): LoaderReport[];
|
|
@@ -61,15 +65,6 @@ export declare class WorkerAdapter<ConnectorState> {
|
|
|
61
65
|
*/
|
|
62
66
|
emit(newEventType: ExtractorEventType | LoaderEventType, data?: EventData): Promise<void>;
|
|
63
67
|
uploadAllRepos(): Promise<void>;
|
|
64
|
-
/**
|
|
65
|
-
* Persists adapter state before emitting, except for stateless worker phases.
|
|
66
|
-
*/
|
|
67
|
-
private postStateBeforeEmit;
|
|
68
|
-
/**
|
|
69
|
-
* Posts state (when required), emits to the platform, and notifies the parent
|
|
70
|
-
* worker that an event was emitted.
|
|
71
|
-
*/
|
|
72
|
-
private emitToPlatform;
|
|
73
68
|
loadItemTypes({ itemTypesToLoad, }: ItemTypesToLoadParams): Promise<LoadItemTypesResponse>;
|
|
74
69
|
getLoaderBatches({ supportedItemTypes, }: {
|
|
75
70
|
supportedItemTypes: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-adapter.d.ts","sourceRoot":"","sources":["../../../src/multithreading/worker-adapter/worker-adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"worker-adapter.d.ts","sourceRoot":"","sources":["../../../src/multithreading/worker-adapter/worker-adapter.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EACL,oBAA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IAyG5B,QAAQ,CAAC,EACb,IAAI,EACJ,cAAc,GACf,EAAE;QACD,IAAI,EAAE,kBAAkB,CAAC;QACzB,cAAc,EAAE,cAAc,CAAC;KAChC,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAwMvB,iBAAiB,CACrB,UAAU,EAAE,oBAAoB,EAChC,MAAM,EAAE,yCAAyC,GAChD,OAAO,CAAC,2BAA2B,CAAC;IAoHvC;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAcnB,cAAc,CAAC,EACnB,IAAI,EACJ,MAAM,GACP,EAAE;QACD,IAAI,EAAE,wBAAwB,CAAC;QAC/B,MAAM,EAAE,6BAA6B,CAAC,wBAAwB,CAAC,CAAC;KACjE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAuD7B;;;;;;OAMG;IACG,iBAAiB,CAAC,QAAQ,EAAE,EAChC,MAAM,EACN,UAAU,EACV,SAAa,GACd,EAAE;QACD,MAAM,EAAE,yCAAyC,CAAC;QAClD,UAAU,CAAC,EAAE,kCAAkC,CAC7C,cAAc,EACd,oBAAoB,EAAE,EACtB,QAAQ,CACT,CAAC;QACF,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAuIzC"}
|
|
@@ -114,25 +114,19 @@ describe(`${worker_adapter_1.WorkerAdapter.name}.emit`, () => {
|
|
|
114
114
|
// Assert
|
|
115
115
|
expect(mockPostMessage).toHaveBeenCalledTimes(1);
|
|
116
116
|
});
|
|
117
|
-
it('should emit
|
|
118
|
-
|
|
117
|
+
it('should correctly emit one event even if uploadAllRepos errors', async () => {
|
|
118
|
+
// Arrange
|
|
119
119
|
adapter['adapterState'].postState = jest.fn().mockResolvedValue(undefined);
|
|
120
120
|
adapter.uploadAllRepos = jest
|
|
121
121
|
.fn()
|
|
122
122
|
.mockRejectedValue(new Error('uploadAllRepos error'));
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}),
|
|
131
|
-
}));
|
|
132
|
-
expect(mockPostMessage).toHaveBeenCalledWith(expect.objectContaining({
|
|
133
|
-
subject: 'emit',
|
|
134
|
-
payload: { eventType: types_1.ExtractorEventType.DataExtractionError },
|
|
135
|
-
}));
|
|
123
|
+
// Act
|
|
124
|
+
await adapter.emit(types_1.ExtractorEventType.MetadataExtractionError, {
|
|
125
|
+
reports: [],
|
|
126
|
+
processed_files: [],
|
|
127
|
+
});
|
|
128
|
+
// Assert
|
|
129
|
+
expect(mockPostMessage).toHaveBeenCalledTimes(1);
|
|
136
130
|
});
|
|
137
131
|
it('should include artifacts in data for extraction events', async () => {
|
|
138
132
|
// Arrange
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const attachments_streaming_pool_1 = require("../../attachments-streaming/attachments-streaming-pool");
|
|
4
|
-
const test_utils_1 = require("../../common/test-utils");
|
|
5
4
|
const state_1 = require("../../state/state");
|
|
6
5
|
const jest_setup_1 = require("../../tests/jest.setup");
|
|
6
|
+
const test_utils_1 = require("../../common/test-utils");
|
|
7
7
|
const types_1 = require("../../types");
|
|
8
8
|
const worker_adapter_1 = require("./worker-adapter");
|
|
9
9
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
@@ -19,4 +19,5 @@ export declare function addReportToLoaderReport({ loaderReports, report, }: {
|
|
|
19
19
|
loaderReports: LoaderReport[];
|
|
20
20
|
report: LoaderReport;
|
|
21
21
|
}): LoaderReport[];
|
|
22
|
+
export declare function toRfc3339Timestamp(ms: number): string | undefined;
|
|
22
23
|
//# sourceMappingURL=worker-adapter.helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-adapter.helpers.d.ts","sourceRoot":"","sources":["../../../src/multithreading/worker-adapter/worker-adapter.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,YAAY,EACZ,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAE7B;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC7B,kBAAkB,EAClB,SAAS,GACV,EAAE;IACD,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,SAAS,EAAE,eAAe,EAAE,CAAC;CAC9B,GAAG,UAAU,EAAE,CA8Bf;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,aAAa,EACb,MAAM,GACP,EAAE;IACD,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,MAAM,EAAE,YAAY,CAAC;CACtB,GAAG,YAAY,EAAE,CA4BjB"}
|
|
1
|
+
{"version":3,"file":"worker-adapter.helpers.d.ts","sourceRoot":"","sources":["../../../src/multithreading/worker-adapter/worker-adapter.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,YAAY,EACZ,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAE7B;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC7B,kBAAkB,EAClB,SAAS,GACV,EAAE;IACD,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,SAAS,EAAE,eAAe,EAAE,CAAC;CAC9B,GAAG,UAAU,EAAE,CA8Bf;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,aAAa,EACb,MAAM,GACP,EAAE;IACD,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,MAAM,EAAE,YAAY,CAAC;CACtB,GAAG,YAAY,EAAE,CA4BjB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMjE"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFilesToLoad = getFilesToLoad;
|
|
4
4
|
exports.addReportToLoaderReport = addReportToLoaderReport;
|
|
5
|
+
exports.toRfc3339Timestamp = toRfc3339Timestamp;
|
|
5
6
|
const loading_1 = require("../../types/loading");
|
|
6
7
|
/**
|
|
7
8
|
* Gets the files to load for the loader.
|
|
@@ -62,3 +63,9 @@ function addReportToLoaderReport({ loaderReports, report, }) {
|
|
|
62
63
|
}
|
|
63
64
|
return loaderReports;
|
|
64
65
|
}
|
|
66
|
+
function toRfc3339Timestamp(ms) {
|
|
67
|
+
if (!Number.isFinite(ms) || ms === 0) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return new Date(ms).toISOString();
|
|
71
|
+
}
|
|
@@ -22,13 +22,6 @@ const workers_1 = require("../../types/workers");
|
|
|
22
22
|
const uploader_1 = require("../../uploader/uploader");
|
|
23
23
|
const event_type_translation_1 = require("../../common/event-type-translation");
|
|
24
24
|
const helpers_1 = require("../../common/helpers");
|
|
25
|
-
const spawn_helpers_1 = require("../spawn/spawn.helpers");
|
|
26
|
-
function toRfc3339Timestamp(ms) {
|
|
27
|
-
if (!Number.isFinite(ms) || ms === 0) {
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
return new Date(ms).toISOString();
|
|
31
|
-
}
|
|
32
25
|
function createWorkerAdapter({ event, adapterState, options, }) {
|
|
33
26
|
return new WorkerAdapter({
|
|
34
27
|
event,
|
|
@@ -53,6 +46,10 @@ function createWorkerAdapter({ event, adapterState, options, }) {
|
|
|
53
46
|
*/
|
|
54
47
|
class WorkerAdapter {
|
|
55
48
|
constructor({ event, adapterState, options, }) {
|
|
49
|
+
this._isTimeout = false;
|
|
50
|
+
this.timeoutSignal = new Promise((resolve) => {
|
|
51
|
+
this.resolveTimeoutSignal = resolve;
|
|
52
|
+
});
|
|
56
53
|
this.repos = [];
|
|
57
54
|
this.currentEventDataLength = 0;
|
|
58
55
|
this.event = event;
|
|
@@ -60,7 +57,6 @@ class WorkerAdapter {
|
|
|
60
57
|
this.adapterState = adapterState;
|
|
61
58
|
this._artifacts = [];
|
|
62
59
|
this.hasWorkerEmitted = false;
|
|
63
|
-
this.isTimeout = false;
|
|
64
60
|
// Loader
|
|
65
61
|
this.loaderReports = [];
|
|
66
62
|
this._processedFiles = [];
|
|
@@ -73,6 +69,15 @@ class WorkerAdapter {
|
|
|
73
69
|
options,
|
|
74
70
|
});
|
|
75
71
|
}
|
|
72
|
+
get isTimeout() {
|
|
73
|
+
return this._isTimeout;
|
|
74
|
+
}
|
|
75
|
+
set isTimeout(value) {
|
|
76
|
+
this._isTimeout = value;
|
|
77
|
+
if (value) {
|
|
78
|
+
this.resolveTimeoutSignal();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
76
81
|
get state() {
|
|
77
82
|
return this.adapterState.state;
|
|
78
83
|
}
|
|
@@ -154,7 +159,7 @@ class WorkerAdapter {
|
|
|
154
159
|
*/
|
|
155
160
|
async emit(newEventType, data) {
|
|
156
161
|
return (0, logger_context_1.runWithSdkLogContext)(async () => {
|
|
157
|
-
var _a;
|
|
162
|
+
var _a, _b;
|
|
158
163
|
newEventType = (0, event_type_translation_1.translateOutgoingEventType)(newEventType);
|
|
159
164
|
if (this.hasWorkerEmitted) {
|
|
160
165
|
console.warn(`Trying to emit event with event type: ${newEventType}. Ignoring emit request because it has already been emitted.`);
|
|
@@ -186,13 +191,8 @@ class WorkerAdapter {
|
|
|
186
191
|
}
|
|
187
192
|
catch (error) {
|
|
188
193
|
console.error('Error while uploading repos', error);
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
const { eventType } = (0, spawn_helpers_1.getTimeoutErrorEventType)(this.event.payload.event_type);
|
|
193
|
-
await this.emitToPlatform(eventType, {
|
|
194
|
-
error: { message: (0, logger_1.serializeError)(error) },
|
|
195
|
-
});
|
|
194
|
+
node_worker_threads_1.parentPort === null || node_worker_threads_1.parentPort === void 0 ? void 0 : node_worker_threads_1.parentPort.postMessage(workers_1.WorkerMessageSubject.WorkerMessageExit);
|
|
195
|
+
this.hasWorkerEmitted = true;
|
|
196
196
|
return;
|
|
197
197
|
}
|
|
198
198
|
// If the extraction is done, we want to save the timestamp of the last successful sync
|
|
@@ -220,87 +220,73 @@ class WorkerAdapter {
|
|
|
220
220
|
this.state.workersNewest = extractionEnd;
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
|
|
223
|
+
// We want to save the state every time we emit an event, except for the start and delete events
|
|
224
|
+
if (!constants_1.STATELESS_EVENT_TYPES.includes(this.event.payload.event_type)) {
|
|
225
|
+
console.log(`Saving state before emitting event with event type: ${newEventType}.`);
|
|
226
|
+
try {
|
|
227
|
+
await this.adapterState.postState(this.state);
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
console.error('Error while posting state', error);
|
|
231
|
+
node_worker_threads_1.parentPort === null || node_worker_threads_1.parentPort === void 0 ? void 0 : node_worker_threads_1.parentPort.postMessage(workers_1.WorkerMessageSubject.WorkerMessageExit);
|
|
232
|
+
this.hasWorkerEmitted = true;
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
// Always prune error messages to make them shorter before emit
|
|
238
|
+
if ((_b = data === null || data === void 0 ? void 0 : data.error) === null || _b === void 0 ? void 0 : _b.message) {
|
|
239
|
+
data.error.message = (0, helpers_1.truncateMessage)(data.error.message);
|
|
240
|
+
}
|
|
241
|
+
const isExtractionEvent = Object.values(extraction_1.ExtractorEventType).includes(newEventType);
|
|
242
|
+
const isLoaderEvent = Object.values(loading_1.LoaderEventType).includes(newEventType);
|
|
243
|
+
const progressData = {};
|
|
244
|
+
if (isExtractionEvent &&
|
|
245
|
+
(newEventType == extraction_1.ExtractorEventType.DataExtractionDone ||
|
|
246
|
+
newEventType == extraction_1.ExtractorEventType.DataExtractionProgress ||
|
|
247
|
+
newEventType == extraction_1.ExtractorEventType.AttachmentExtractionDone ||
|
|
248
|
+
newEventType == extraction_1.ExtractorEventType.AttachmentExtractionProgress)) {
|
|
249
|
+
const repo = this.lastExtractedItemType
|
|
250
|
+
? this.repos.find((r) => r.itemType === this.lastExtractedItemType)
|
|
251
|
+
: undefined;
|
|
252
|
+
if (repo) {
|
|
253
|
+
progressData.item_type = repo.itemType;
|
|
254
|
+
progressData.newest_created_date = (0, worker_adapter_helpers_1.toRfc3339Timestamp)(repo.dateRanges.creationDate.newest);
|
|
255
|
+
progressData.oldest_created_date = (0, worker_adapter_helpers_1.toRfc3339Timestamp)(repo.dateRanges.creationDate.oldest);
|
|
256
|
+
progressData.newest_modified_date = (0, worker_adapter_helpers_1.toRfc3339Timestamp)(repo.dateRanges.modifiedDate.newest);
|
|
257
|
+
progressData.oldest_modified_date = (0, worker_adapter_helpers_1.toRfc3339Timestamp)(repo.dateRanges.modifiedDate.oldest);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
await (0, control_protocol_1.emit)({
|
|
261
|
+
eventType: newEventType,
|
|
262
|
+
event: this.event,
|
|
263
|
+
data: Object.assign(Object.assign(Object.assign({}, data), (isExtractionEvent ? { artifacts: this.artifacts } : {})), (isLoaderEvent
|
|
264
|
+
? { reports: this.reports, processed_files: this.processedFiles }
|
|
265
|
+
: {})),
|
|
266
|
+
worker_metadata: Object.assign({}, progressData),
|
|
267
|
+
});
|
|
268
|
+
const message = {
|
|
269
|
+
subject: workers_1.WorkerMessageSubject.WorkerMessageEmitted,
|
|
270
|
+
payload: { eventType: newEventType },
|
|
271
|
+
};
|
|
272
|
+
this.artifacts = [];
|
|
273
|
+
node_worker_threads_1.parentPort === null || node_worker_threads_1.parentPort === void 0 ? void 0 : node_worker_threads_1.parentPort.postMessage(message);
|
|
274
|
+
this.hasWorkerEmitted = true;
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
console.error(`Error while emitting event with event type: ${newEventType}.`, (0, logger_1.serializeError)(error));
|
|
278
|
+
node_worker_threads_1.parentPort === null || node_worker_threads_1.parentPort === void 0 ? void 0 : node_worker_threads_1.parentPort.postMessage(workers_1.WorkerMessageSubject.WorkerMessageExit);
|
|
279
|
+
this.hasWorkerEmitted = true;
|
|
280
|
+
}
|
|
224
281
|
});
|
|
225
282
|
}
|
|
226
283
|
async uploadAllRepos() {
|
|
227
284
|
for (const repo of this.repos) {
|
|
228
|
-
await repo.upload();
|
|
285
|
+
const error = await repo.upload();
|
|
229
286
|
this.artifacts.push(...repo.uploadedArtifacts);
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
* Persists adapter state before emitting, except for stateless worker phases.
|
|
234
|
-
*/
|
|
235
|
-
async postStateBeforeEmit(eventType) {
|
|
236
|
-
if (constants_1.STATELESS_EVENT_TYPES.includes(this.event.payload.event_type)) {
|
|
237
|
-
return true;
|
|
238
|
-
}
|
|
239
|
-
console.log(`Saving state before emitting event with event type: ${eventType}.`);
|
|
240
|
-
try {
|
|
241
|
-
await this.adapterState.postState(this.state);
|
|
242
|
-
return true;
|
|
243
|
-
}
|
|
244
|
-
catch (error) {
|
|
245
|
-
console.error('Error while posting state', error);
|
|
246
|
-
node_worker_threads_1.parentPort === null || node_worker_threads_1.parentPort === void 0 ? void 0 : node_worker_threads_1.parentPort.postMessage(workers_1.WorkerMessageSubject.WorkerMessageExit);
|
|
247
|
-
this.hasWorkerEmitted = true;
|
|
248
|
-
return false;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Posts state (when required), emits to the platform, and notifies the parent
|
|
253
|
-
* worker that an event was emitted.
|
|
254
|
-
*/
|
|
255
|
-
async emitToPlatform(eventType, data) {
|
|
256
|
-
var _a;
|
|
257
|
-
const posted = await this.postStateBeforeEmit(eventType);
|
|
258
|
-
if (!posted) {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
try {
|
|
262
|
-
if ((_a = data === null || data === void 0 ? void 0 : data.error) === null || _a === void 0 ? void 0 : _a.message) {
|
|
263
|
-
data.error.message = (0, helpers_1.truncateMessage)(data.error.message);
|
|
264
|
-
}
|
|
265
|
-
const isExtractionEvent = Object.values(extraction_1.ExtractorEventType).includes(eventType);
|
|
266
|
-
const isLoaderEvent = Object.values(loading_1.LoaderEventType).includes(eventType);
|
|
267
|
-
const progress_data = {};
|
|
268
|
-
if (isExtractionEvent &&
|
|
269
|
-
(eventType == extraction_1.ExtractorEventType.DataExtractionDone ||
|
|
270
|
-
eventType == extraction_1.ExtractorEventType.DataExtractionProgress ||
|
|
271
|
-
eventType == extraction_1.ExtractorEventType.AttachmentExtractionDone ||
|
|
272
|
-
eventType == extraction_1.ExtractorEventType.AttachmentExtractionProgress)) {
|
|
273
|
-
const repo = this.lastExtractedItemType
|
|
274
|
-
? this.repos.find((r) => r.itemType === this.lastExtractedItemType)
|
|
275
|
-
: undefined;
|
|
276
|
-
if (repo) {
|
|
277
|
-
progress_data.item_type = repo.itemType;
|
|
278
|
-
progress_data.newest_created_date = toRfc3339Timestamp(repo.dateRanges.creationDate.newest);
|
|
279
|
-
progress_data.oldest_created_date = toRfc3339Timestamp(repo.dateRanges.creationDate.oldest);
|
|
280
|
-
progress_data.newest_modified_date = toRfc3339Timestamp(repo.dateRanges.modifiedDate.newest);
|
|
281
|
-
progress_data.oldest_modified_date = toRfc3339Timestamp(repo.dateRanges.modifiedDate.oldest);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
await (0, control_protocol_1.emit)({
|
|
285
|
-
eventType,
|
|
286
|
-
event: this.event,
|
|
287
|
-
data: Object.assign(Object.assign(Object.assign({}, data), (isExtractionEvent ? { artifacts: this.artifacts } : {})), (isLoaderEvent
|
|
288
|
-
? { reports: this.reports, processed_files: this.processedFiles }
|
|
289
|
-
: {})),
|
|
290
|
-
worker_metadata: Object.assign({}, progress_data),
|
|
291
|
-
});
|
|
292
|
-
const message = {
|
|
293
|
-
subject: workers_1.WorkerMessageSubject.WorkerMessageEmitted,
|
|
294
|
-
payload: { eventType },
|
|
295
|
-
};
|
|
296
|
-
this.artifacts = [];
|
|
297
|
-
node_worker_threads_1.parentPort === null || node_worker_threads_1.parentPort === void 0 ? void 0 : node_worker_threads_1.parentPort.postMessage(message);
|
|
298
|
-
this.hasWorkerEmitted = true;
|
|
299
|
-
}
|
|
300
|
-
catch (error) {
|
|
301
|
-
console.error(`Error while emitting event with event type: ${eventType}.`, (0, logger_1.serializeError)(error));
|
|
302
|
-
node_worker_threads_1.parentPort === null || node_worker_threads_1.parentPort === void 0 ? void 0 : node_worker_threads_1.parentPort.postMessage(workers_1.WorkerMessageSubject.WorkerMessageExit);
|
|
303
|
-
this.hasWorkerEmitted = true;
|
|
287
|
+
if (error) {
|
|
288
|
+
throw error;
|
|
289
|
+
}
|
|
304
290
|
}
|
|
305
291
|
}
|
|
306
292
|
async loadItemTypes({ itemTypesToLoad, }) {
|
|
@@ -736,6 +722,10 @@ class WorkerAdapter {
|
|
|
736
722
|
else if (attachment.inline === false) {
|
|
737
723
|
ssorAttachment.inline = false;
|
|
738
724
|
}
|
|
725
|
+
if (this.isTimeout) {
|
|
726
|
+
this.destroyHttpStream(httpStream);
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
739
729
|
await ((_c = this.getRepo('ssor_attachment')) === null || _c === void 0 ? void 0 : _c.push([ssorAttachment]));
|
|
740
730
|
return;
|
|
741
731
|
}
|
package/dist/repo/repo.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Item } from '../repo/repo.interfaces';
|
|
2
|
+
import { ErrorRecord } from '../types/common';
|
|
2
3
|
import { Artifact } from '../uploader/uploader.interfaces';
|
|
3
4
|
import { NormalizedAttachment, NormalizedItem, RepoFactoryInterface } from './repo.interfaces';
|
|
4
5
|
export declare class Repo {
|
|
@@ -21,7 +22,7 @@ export declare class Repo {
|
|
|
21
22
|
};
|
|
22
23
|
constructor({ event, itemType, normalize, onUpload, options, }: RepoFactoryInterface);
|
|
23
24
|
getItems(): (NormalizedItem | NormalizedAttachment | Item)[];
|
|
24
|
-
upload(batch?: (NormalizedItem | NormalizedAttachment | Item)[]): Promise<void>;
|
|
25
|
+
upload(batch?: (NormalizedItem | NormalizedAttachment | Item)[]): Promise<void | ErrorRecord>;
|
|
25
26
|
push(items: Item[]): Promise<boolean>;
|
|
26
27
|
}
|
|
27
28
|
//# sourceMappingURL=repo.d.ts.map
|
package/dist/repo/repo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../src/repo/repo.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../src/repo/repo.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAI3D,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAM3B,qBAAa,IAAI;IACf,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,KAAK,CAAmD;IAChE,OAAO,CAAC,SAAS,CAAC,CAAwD;IAC1E,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,OAAO,CAAC,CAAuB;IAChC,iBAAiB,EAAE,QAAQ,EAAE,CAAC;IAC9B,UAAU;;;;;;;;;MAGf;gBAEU,EACV,KAAK,EACL,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,OAAO,GACR,EAAE,oBAAoB;IAUvB,QAAQ,IAAI,CAAC,cAAc,GAAG,oBAAoB,GAAG,IAAI,CAAC,EAAE;IAItD,MAAM,CACV,KAAK,CAAC,EAAE,CAAC,cAAc,GAAG,oBAAoB,GAAG,IAAI,CAAC,EAAE,GACvD,OAAO,CAAC,IAAI,GAAG,WAAW,CAAC;IAsDxB,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAyC5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo.helpers.d.ts","sourceRoot":"","sources":["../../src/repo/repo.helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CACzB,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACzC,EAAE,EAAE,MAAM,GACT,IAAI,CAON;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGlE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateRange = updateRange;
|
|
4
|
+
exports.toValidTimestamp = toValidTimestamp;
|
|
5
|
+
function updateRange(range, ms) {
|
|
6
|
+
if (range.oldest === 0 || ms < range.oldest) {
|
|
7
|
+
range.oldest = ms;
|
|
8
|
+
}
|
|
9
|
+
if (range.newest === 0 || ms > range.newest) {
|
|
10
|
+
range.newest = ms;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function toValidTimestamp(value) {
|
|
14
|
+
const ms = new Date(value).getTime();
|
|
15
|
+
return Number.isFinite(ms) ? ms : undefined;
|
|
16
|
+
}
|
package/dist/repo/repo.js
CHANGED
|
@@ -4,18 +4,7 @@ exports.Repo = void 0;
|
|
|
4
4
|
const constants_1 = require("../common/constants");
|
|
5
5
|
const uploader_1 = require("../uploader/uploader");
|
|
6
6
|
const logger_context_1 = require("../logger/logger.context");
|
|
7
|
-
|
|
8
|
-
if (range.oldest === 0 || ms < range.oldest) {
|
|
9
|
-
range.oldest = ms;
|
|
10
|
-
}
|
|
11
|
-
if (range.newest === 0 || ms > range.newest) {
|
|
12
|
-
range.newest = ms;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function toValidTimestamp(value) {
|
|
16
|
-
const ms = new Date(value).getTime();
|
|
17
|
-
return Number.isFinite(ms) ? ms : undefined;
|
|
18
|
-
}
|
|
7
|
+
const repo_helpers_1 = require("./repo.helpers");
|
|
19
8
|
class Repo {
|
|
20
9
|
constructor({ event, itemType, normalize, onUpload, options, }) {
|
|
21
10
|
this.dateRanges = {
|
|
@@ -34,22 +23,21 @@ class Repo {
|
|
|
34
23
|
return this.items;
|
|
35
24
|
}
|
|
36
25
|
async upload(batch) {
|
|
37
|
-
var _a;
|
|
38
26
|
const itemsToUpload = batch || this.items;
|
|
39
27
|
if (itemsToUpload.length > 0) {
|
|
40
28
|
for (const item of itemsToUpload) {
|
|
41
29
|
const createdDate = item === null || item === void 0 ? void 0 : item.created_date;
|
|
42
30
|
if (createdDate != null) {
|
|
43
|
-
const createdMs = toValidTimestamp(createdDate);
|
|
31
|
+
const createdMs = (0, repo_helpers_1.toValidTimestamp)(createdDate);
|
|
44
32
|
if (createdMs !== undefined) {
|
|
45
|
-
updateRange(this.dateRanges.creationDate, createdMs);
|
|
33
|
+
(0, repo_helpers_1.updateRange)(this.dateRanges.creationDate, createdMs);
|
|
46
34
|
}
|
|
47
35
|
}
|
|
48
36
|
const modifiedDate = item === null || item === void 0 ? void 0 : item.modified_date;
|
|
49
37
|
if (modifiedDate != null && modifiedDate !== '') {
|
|
50
|
-
const modifiedMs = toValidTimestamp(modifiedDate);
|
|
38
|
+
const modifiedMs = (0, repo_helpers_1.toValidTimestamp)(modifiedDate);
|
|
51
39
|
if (modifiedMs !== undefined) {
|
|
52
|
-
updateRange(this.dateRanges.modifiedDate, modifiedMs);
|
|
40
|
+
(0, repo_helpers_1.updateRange)(this.dateRanges.modifiedDate, modifiedMs);
|
|
53
41
|
}
|
|
54
42
|
}
|
|
55
43
|
}
|
|
@@ -57,7 +45,7 @@ class Repo {
|
|
|
57
45
|
const { artifact, error } = await this.uploader.upload(this.itemType, itemsToUpload);
|
|
58
46
|
if (error || !artifact) {
|
|
59
47
|
console.error('Error while uploading batch', error);
|
|
60
|
-
|
|
48
|
+
return error;
|
|
61
49
|
}
|
|
62
50
|
this.onUpload(artifact);
|
|
63
51
|
this.uploadedArtifacts.push(artifact);
|
|
@@ -92,9 +80,16 @@ class Repo {
|
|
|
92
80
|
// Upload in batches while the number of items exceeds the batch size
|
|
93
81
|
const batchSize = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.batchSize) || constants_1.ARTIFACT_BATCH_SIZE;
|
|
94
82
|
while (this.items.length >= batchSize) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
83
|
+
// Slice out a batch of batchSize items to upload
|
|
84
|
+
const batch = this.items.splice(0, batchSize);
|
|
85
|
+
try {
|
|
86
|
+
// Upload the batch
|
|
87
|
+
await this.upload(batch);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
console.error('Error while uploading batch', error);
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
98
93
|
}
|
|
99
94
|
return true;
|
|
100
95
|
}
|
package/dist/repo/repo.test.js
CHANGED
|
@@ -304,7 +304,7 @@ describe(repo_1.Repo.name, () => {
|
|
|
304
304
|
error: new Error('fail'),
|
|
305
305
|
artifact: null,
|
|
306
306
|
});
|
|
307
|
-
await
|
|
307
|
+
await repo.upload([itemWithDate('1', '2022-01-01T00:00:00.000Z')]);
|
|
308
308
|
expect(repo.dateRanges.creationDate.oldest).toBe(ts('2022-01-01T00:00:00.000Z'));
|
|
309
309
|
expect(repo.dateRanges.creationDate.newest).toBe(ts('2022-01-01T00:00:00.000Z'));
|
|
310
310
|
});
|
|
@@ -334,35 +334,4 @@ describe(repo_1.Repo.name, () => {
|
|
|
334
334
|
expect(repo.dateRanges.modifiedDate.newest).toBe(ts('2023-01-01T00:00:00.000Z'));
|
|
335
335
|
});
|
|
336
336
|
});
|
|
337
|
-
it('should throw when upload fails', async () => {
|
|
338
|
-
mockUploadFn.mockResolvedValueOnce({
|
|
339
|
-
error: { message: 'upload failed' },
|
|
340
|
-
});
|
|
341
|
-
await expect(repo.upload((0, test_helpers_1.createItems)(1))).rejects.toThrow('upload failed');
|
|
342
|
-
});
|
|
343
|
-
it('should retain items in repo when batch upload fails during push', async () => {
|
|
344
|
-
repo = new repo_1.Repo({
|
|
345
|
-
event: (0, test_utils_1.createMockEvent)(jest_setup_1.mockServer.baseUrl, {
|
|
346
|
-
payload: { event_type: types_1.EventType.ExtractionDataStart },
|
|
347
|
-
}),
|
|
348
|
-
itemType: 'test_item_type',
|
|
349
|
-
normalize,
|
|
350
|
-
onUpload: jest.fn(),
|
|
351
|
-
options: { batchSize: 10 },
|
|
352
|
-
});
|
|
353
|
-
const items = (0, test_helpers_1.createItems)(20);
|
|
354
|
-
mockUploadFn
|
|
355
|
-
.mockResolvedValueOnce({
|
|
356
|
-
artifact: {
|
|
357
|
-
id: 'artifact-1',
|
|
358
|
-
item_type: 'test_item_type',
|
|
359
|
-
item_count: 10,
|
|
360
|
-
},
|
|
361
|
-
})
|
|
362
|
-
.mockResolvedValueOnce({
|
|
363
|
-
error: { message: 'second batch failed' },
|
|
364
|
-
});
|
|
365
|
-
await expect(repo.push(items)).rejects.toThrow('second batch failed');
|
|
366
|
-
expect(repo.getItems().length).toBe(10);
|
|
367
|
-
});
|
|
368
337
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extraction.d.ts","sourceRoot":"","sources":["../../src/types/extraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,W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D,cAAc,EACd,KAAK,EACL,QAAQ;IAER,OAAO,EAAE,uCAAuC,CAC9C,KAAK,EACL,QAAQ,EACR,cAAc,CACf,CAAC;IACF,QAAQ,EAAE,wCAAwC,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;CAC9E"}
|
package/dist/types/workers.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Worker } from 'worker_threads';
|
|
2
|
-
import type { Logger } from '../logger/logger';
|
|
3
2
|
import type { LogLevel } from '../logger/logger.interfaces';
|
|
4
3
|
import { State } from '../state/state';
|
|
5
4
|
import { WorkerAdapter } from '../multithreading/worker-adapter/worker-adapter';
|
|
@@ -41,8 +40,6 @@ export interface WorkerAdapterOptions {
|
|
|
41
40
|
batchSize?: number;
|
|
42
41
|
workerPathOverrides?: WorkerPathOverrides;
|
|
43
42
|
skipConfirmation?: boolean;
|
|
44
|
-
/** Test-only: limits axios-retry attempts inside worker threads (see axios-client-internal). */
|
|
45
|
-
httpRetries?: number;
|
|
46
43
|
}
|
|
47
44
|
/**
|
|
48
45
|
* SpawnInterface is an interface for Spawn class.
|
|
@@ -57,7 +54,6 @@ export interface SpawnInterface {
|
|
|
57
54
|
options?: WorkerAdapterOptions;
|
|
58
55
|
resolve: (value: void | PromiseLike<void>) => void;
|
|
59
56
|
originalConsole?: Console;
|
|
60
|
-
logger?: Logger;
|
|
61
57
|
}
|
|
62
58
|
/**
|
|
63
59
|
* SpawnFactoryInterface is an interface for Spawn class factory.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workers.d.ts","sourceRoot":"","sources":["../../src/types/workers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"workers.d.ts","sourceRoot":"","sources":["../../src/types/workers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;A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C;QAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;CACH;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,oBAAoB,CAAC,mBAAmB,CAAC;IAClD,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,oBAAoB,GACpB,iBAAiB,GACjB,gBAAgB,GAChB,mBAAmB,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,cAAc;IACxC,KAAK,EAAE,YAAY,CAAC;IACpB,YAAY,EAAE,cAAc,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,YAAY,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../src/uploader/uploader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../src/uploader/uploader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAMtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAW/D,OAAO,EAEL,gBAAgB,EAChB,cAAc,EACd,wBAAwB,EACxB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,QAAQ;IACnB,OAAO,CAAC,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AIG;YACW,sBAAsB;IAsBpC;;;;OAIG;YACW,gBAAgB;IAc9B;;;;;;OAMG;IACG,yBAAyB,CAAC,EAC9B,UAAU,EACV,SAAiB,GAClB,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;CA6B/C"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worker-adapter.upload-failure.test.d.ts","sourceRoot":"","sources":["../../../src/multithreading/worker-adapter/worker-adapter.upload-failure.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const state_1 = require("../../state/state");
|
|
4
|
-
const jest_setup_1 = require("../../tests/jest.setup");
|
|
5
|
-
const test_helpers_1 = require("../../tests/test-helpers");
|
|
6
|
-
const test_utils_1 = require("../../common/test-utils");
|
|
7
|
-
const types_1 = require("../../types");
|
|
8
|
-
const worker_adapter_1 = require("./worker-adapter");
|
|
9
|
-
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
10
|
-
jest.mock('../../common/control-protocol', () => ({
|
|
11
|
-
emit: jest.fn().mockResolvedValue({}),
|
|
12
|
-
}));
|
|
13
|
-
jest.mock('../../mappers/mappers');
|
|
14
|
-
jest.mock('node:worker_threads', () => ({
|
|
15
|
-
parentPort: { postMessage: jest.fn() },
|
|
16
|
-
}));
|
|
17
|
-
jest.mock('../../attachments-streaming/attachments-streaming-pool', () => ({
|
|
18
|
-
AttachmentsStreamingPool: jest.fn().mockImplementation(() => ({
|
|
19
|
-
streamAll: jest.fn().mockResolvedValue(undefined),
|
|
20
|
-
})),
|
|
21
|
-
}));
|
|
22
|
-
const UPLOAD_URL_PATH = '/internal/airdrop.artifacts.upload-url';
|
|
23
|
-
function makeAdapter() {
|
|
24
|
-
const event = (0, test_utils_1.createMockEvent)(jest_setup_1.mockServer.baseUrl, {
|
|
25
|
-
payload: { event_type: types_1.EventType.StartExtractingData },
|
|
26
|
-
});
|
|
27
|
-
const initialState = {
|
|
28
|
-
attachments: { completed: false },
|
|
29
|
-
lastSyncStarted: '',
|
|
30
|
-
lastSuccessfulSyncStarted: '',
|
|
31
|
-
snapInVersionId: '',
|
|
32
|
-
toDevRev: {
|
|
33
|
-
attachmentsMetadata: {
|
|
34
|
-
artifactIds: [],
|
|
35
|
-
lastProcessed: 0,
|
|
36
|
-
lastProcessedAttachmentsIdsList: [],
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
const adapterState = new state_1.State({ event, initialState });
|
|
41
|
-
const adapter = new worker_adapter_1.WorkerAdapter({ event, adapterState });
|
|
42
|
-
const workerThreads = require('node:worker_threads');
|
|
43
|
-
const mockPostMessage = jest.fn();
|
|
44
|
-
if (workerThreads.parentPort) {
|
|
45
|
-
jest
|
|
46
|
-
.spyOn(workerThreads.parentPort, 'postMessage')
|
|
47
|
-
.mockImplementation(mockPostMessage);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
workerThreads.parentPort = { postMessage: mockPostMessage };
|
|
51
|
-
}
|
|
52
|
-
return { adapter, mockPostMessage };
|
|
53
|
-
}
|
|
54
|
-
describe(`${worker_adapter_1.WorkerAdapter.name} upload failure (near-integration)`, () => {
|
|
55
|
-
let adapter;
|
|
56
|
-
let mockPostMessage;
|
|
57
|
-
beforeEach(() => {
|
|
58
|
-
jest.clearAllMocks();
|
|
59
|
-
jest_setup_1.mockServer.resetRoutes();
|
|
60
|
-
({ adapter, mockPostMessage } = makeAdapter());
|
|
61
|
-
adapter['adapterState'].postState = jest.fn().mockResolvedValue(undefined);
|
|
62
|
-
});
|
|
63
|
-
afterEach(() => {
|
|
64
|
-
jest.restoreAllMocks();
|
|
65
|
-
});
|
|
66
|
-
it('should throw from repo.push when upload-url returns 400 during batch upload', async () => {
|
|
67
|
-
var _a, _b;
|
|
68
|
-
jest_setup_1.mockServer.setRoute({
|
|
69
|
-
path: UPLOAD_URL_PATH,
|
|
70
|
-
method: 'GET',
|
|
71
|
-
status: 400,
|
|
72
|
-
});
|
|
73
|
-
adapter.initializeRepos([
|
|
74
|
-
{
|
|
75
|
-
itemType: 'tasks',
|
|
76
|
-
overridenOptions: { batchSize: 10 },
|
|
77
|
-
},
|
|
78
|
-
]);
|
|
79
|
-
await expect((_a = adapter.getRepo('tasks')) === null || _a === void 0 ? void 0 : _a.push((0, test_helpers_1.createItems)(20))).rejects.toThrow('artifact upload URL');
|
|
80
|
-
expect((_b = adapter.getRepo('tasks')) === null || _b === void 0 ? void 0 : _b.getItems().length).toBe(20);
|
|
81
|
-
});
|
|
82
|
-
it('should emit DataExtractionError via emitToPlatform when uploadAllRepos fails', async () => {
|
|
83
|
-
var _a;
|
|
84
|
-
const { emit: mockEmit } = require('../../common/control-protocol');
|
|
85
|
-
jest_setup_1.mockServer.setRoute({
|
|
86
|
-
path: UPLOAD_URL_PATH,
|
|
87
|
-
method: 'GET',
|
|
88
|
-
status: 400,
|
|
89
|
-
});
|
|
90
|
-
adapter.initializeRepos([{ itemType: 'tasks' }]);
|
|
91
|
-
await ((_a = adapter.getRepo('tasks')) === null || _a === void 0 ? void 0 : _a.push((0, test_helpers_1.createItems)(5)));
|
|
92
|
-
await adapter.emit(types_1.ExtractorEventType.DataExtractionDone);
|
|
93
|
-
expect(mockEmit).toHaveBeenCalledWith(expect.objectContaining({
|
|
94
|
-
eventType: types_1.ExtractorEventType.DataExtractionError,
|
|
95
|
-
data: expect.objectContaining({
|
|
96
|
-
error: expect.objectContaining({
|
|
97
|
-
message: expect.stringContaining('artifact upload URL'),
|
|
98
|
-
}),
|
|
99
|
-
}),
|
|
100
|
-
}));
|
|
101
|
-
expect(mockPostMessage).toHaveBeenCalledWith(expect.objectContaining({
|
|
102
|
-
subject: 'emit',
|
|
103
|
-
payload: { eventType: types_1.ExtractorEventType.DataExtractionError },
|
|
104
|
-
}));
|
|
105
|
-
});
|
|
106
|
-
it('should include partial artifacts when push batch succeeded before uploadAllRepos fails', async () => {
|
|
107
|
-
var _a;
|
|
108
|
-
const { emit: mockEmit } = require('../../common/control-protocol');
|
|
109
|
-
jest_setup_1.mockServer.setRoute({
|
|
110
|
-
path: UPLOAD_URL_PATH,
|
|
111
|
-
method: 'GET',
|
|
112
|
-
status: 200,
|
|
113
|
-
succeedThenFail: {
|
|
114
|
-
successCount: 1,
|
|
115
|
-
errorStatus: 400,
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
adapter.initializeRepos([
|
|
119
|
-
{
|
|
120
|
-
itemType: 'tasks',
|
|
121
|
-
overridenOptions: { batchSize: 10 },
|
|
122
|
-
},
|
|
123
|
-
]);
|
|
124
|
-
await ((_a = adapter.getRepo('tasks')) === null || _a === void 0 ? void 0 : _a.push((0, test_helpers_1.createItems)(15)));
|
|
125
|
-
await adapter.emit(types_1.ExtractorEventType.DataExtractionDone);
|
|
126
|
-
expect(mockEmit).toHaveBeenCalledWith(expect.objectContaining({
|
|
127
|
-
eventType: types_1.ExtractorEventType.DataExtractionError,
|
|
128
|
-
data: expect.objectContaining({
|
|
129
|
-
artifacts: expect.arrayContaining([
|
|
130
|
-
expect.objectContaining({ item_count: 10, item_type: 'tasks' }),
|
|
131
|
-
]),
|
|
132
|
-
}),
|
|
133
|
-
}));
|
|
134
|
-
});
|
|
135
|
-
});
|