@devrev/ts-adaas 1.12.3-beta.7 → 1.12.3-beta.8

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.
Files changed (50) hide show
  1. package/dist/common/constants.d.ts +1 -1
  2. package/dist/common/constants.d.ts.map +1 -1
  3. package/dist/common/constants.js +1 -1
  4. package/dist/types/common.d.ts +0 -3
  5. package/dist/types/common.d.ts.map +1 -1
  6. package/dist/types/workers.d.ts +0 -58
  7. package/dist/types/workers.d.ts.map +1 -1
  8. package/dist/uploader/uploader.d.ts.map +1 -1
  9. package/dist/uploader/uploader.js +4 -7
  10. package/dist/workers/create-worker.d.ts +2 -20
  11. package/dist/workers/create-worker.d.ts.map +1 -1
  12. package/dist/workers/create-worker.js +3 -38
  13. package/dist/workers/create-worker.test.js +14 -113
  14. package/dist/workers/spawn.d.ts +1 -10
  15. package/dist/workers/spawn.d.ts.map +1 -1
  16. package/dist/workers/spawn.js +3 -77
  17. package/package.json +1 -2
  18. package/dist/common/worker-memory.d.ts +0 -59
  19. package/dist/common/worker-memory.d.ts.map +0 -1
  20. package/dist/common/worker-memory.js +0 -177
  21. package/dist/tests/oom-handling/extraction.d.ts +0 -11
  22. package/dist/tests/oom-handling/extraction.d.ts.map +0 -1
  23. package/dist/tests/oom-handling/extraction.js +0 -29
  24. package/dist/tests/oom-handling/jest.setup.d.ts +0 -7
  25. package/dist/tests/oom-handling/jest.setup.d.ts.map +0 -1
  26. package/dist/tests/oom-handling/jest.setup.js +0 -26
  27. package/dist/tests/oom-handling/oom-after-emit-worker.d.ts +0 -2
  28. package/dist/tests/oom-handling/oom-after-emit-worker.d.ts.map +0 -1
  29. package/dist/tests/oom-handling/oom-after-emit-worker.js +0 -35
  30. package/dist/tests/oom-handling/oom-attachments-worker.d.ts +0 -2
  31. package/dist/tests/oom-handling/oom-attachments-worker.d.ts.map +0 -1
  32. package/dist/tests/oom-handling/oom-attachments-worker.js +0 -29
  33. package/dist/tests/oom-handling/oom-external-sync-units-worker.d.ts +0 -2
  34. package/dist/tests/oom-handling/oom-external-sync-units-worker.d.ts.map +0 -1
  35. package/dist/tests/oom-handling/oom-external-sync-units-worker.js +0 -29
  36. package/dist/tests/oom-handling/oom-gradual-worker.d.ts +0 -2
  37. package/dist/tests/oom-handling/oom-gradual-worker.d.ts.map +0 -1
  38. package/dist/tests/oom-handling/oom-gradual-worker.js +0 -47
  39. package/dist/tests/oom-handling/oom-handling.test.d.ts +0 -2
  40. package/dist/tests/oom-handling/oom-handling.test.d.ts.map +0 -1
  41. package/dist/tests/oom-handling/oom-handling.test.js +0 -407
  42. package/dist/tests/oom-handling/oom-metadata-worker.d.ts +0 -2
  43. package/dist/tests/oom-handling/oom-metadata-worker.d.ts.map +0 -1
  44. package/dist/tests/oom-handling/oom-metadata-worker.js +0 -29
  45. package/dist/tests/oom-handling/oom-worker.d.ts +0 -2
  46. package/dist/tests/oom-handling/oom-worker.d.ts.map +0 -1
  47. package/dist/tests/oom-handling/oom-worker.js +0 -55
  48. package/dist/tests/oom-handling/worker-memory.test.d.ts +0 -2
  49. package/dist/tests/oom-handling/worker-memory.test.d.ts.map +0 -1
  50. package/dist/tests/oom-handling/worker-memory.test.js +0 -306
@@ -1,59 +0,0 @@
1
- import { WorkerMemoryConfig } from '../types/workers';
2
- /**
3
- * Constants for memory limit calculation.
4
- */
5
- export declare const MEMORY_CONSTANTS: {
6
- /** Percentage of memory to allocate to worker thread (75-80%) */
7
- readonly WORKER_MEMORY_PERCENTAGE: 0.75;
8
- /** Maximum memory cap for local development in MB */
9
- readonly LOCAL_DEV_MAX_TOTAL_MEMORY_MB: 1024;
10
- /** Minimum heap size for worker in MB */
11
- readonly MIN_WORKER_HEAP_SIZE_MB: 128;
12
- /** Default heap size when unable to determine system memory */
13
- readonly DEFAULT_WORKER_HEAP_SIZE_MB: 512;
14
- };
15
- /**
16
- * Detects if the current environment is AWS Lambda.
17
- * @returns true if running in AWS Lambda
18
- */
19
- export declare function isLambdaEnvironment(): boolean;
20
- /**
21
- * Gets the AWS Lambda memory limit from environment variable.
22
- * @returns Lambda memory limit in MB, or null if not in Lambda
23
- */
24
- export declare function getLambdaMemoryLimitMb(): number | null;
25
- /**
26
- * Gets the total available memory based on the environment.
27
- * For Lambda: Uses AWS_LAMBDA_FUNCTION_MEMORY_SIZE
28
- * For local development: Caps at LOCAL_DEV_MAX_TOTAL_MEMORY_MB
29
- * For other environments: Uses system total memory or V8 heap limit
30
- *
31
- * @param isLocalDevelopment - Whether running in local development mode
32
- * @returns Total available memory in MB
33
- */
34
- export declare function getTotalAvailableMemoryMb(isLocalDevelopment: boolean): number;
35
- /**
36
- * Calculates the worker memory configuration based on the environment.
37
- *
38
- * @param isLocalDevelopment - Whether running in local development mode
39
- * @returns Worker memory configuration
40
- */
41
- export declare function calculateWorkerMemoryConfig(isLocalDevelopment?: boolean): WorkerMemoryConfig;
42
- /**
43
- * Node.js error code for worker thread OOM.
44
- * @see https://nodejs.org/api/errors.html#err_worker_out_of_memory
45
- */
46
- export declare const ERR_WORKER_OUT_OF_MEMORY = "ERR_WORKER_OUT_OF_MEMORY";
47
- /**
48
- * Checks if an error indicates an OOM (Out-Of-Memory) error.
49
- *
50
- * This function first checks for the Node.js error code `ERR_WORKER_OUT_OF_MEMORY`
51
- * which is the standard way to detect worker thread OOM errors.
52
- * Falls back to regex pattern matching on the error message for other OOM scenarios.
53
- *
54
- * @param error - The error to check (can be an Error object or string message)
55
- * @returns true if the error indicates OOM
56
- * @see https://nodejs.org/api/errors.html#err_worker_out_of_memory
57
- */
58
- export declare function isOOMError(error: Error | string): boolean;
59
- //# sourceMappingURL=worker-memory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker-memory.d.ts","sourceRoot":"","sources":["../../src/common/worker-memory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAC3B,iEAAiE;;IAEjE,qDAAqD;;IAErD,yCAAyC;;IAEzC,+DAA+D;;CAEvD,CAAC;AAEX;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAM7C;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAStD;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,kBAAkB,EAAE,OAAO,GAAG,MAAM,CAsB7E;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,kBAAkB,GAAE,OAAe,GAClC,kBAAkB,CAuBpB;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AAiBnE;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAqBzD"}
@@ -1,177 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ERR_WORKER_OUT_OF_MEMORY = exports.MEMORY_CONSTANTS = void 0;
37
- exports.isLambdaEnvironment = isLambdaEnvironment;
38
- exports.getLambdaMemoryLimitMb = getLambdaMemoryLimitMb;
39
- exports.getTotalAvailableMemoryMb = getTotalAvailableMemoryMb;
40
- exports.calculateWorkerMemoryConfig = calculateWorkerMemoryConfig;
41
- exports.isOOMError = isOOMError;
42
- const os = __importStar(require("os"));
43
- const v8 = __importStar(require("v8"));
44
- /**
45
- * Constants for memory limit calculation.
46
- */
47
- exports.MEMORY_CONSTANTS = {
48
- /** Percentage of memory to allocate to worker thread (75-80%) */
49
- WORKER_MEMORY_PERCENTAGE: 0.75,
50
- /** Maximum memory cap for local development in MB */
51
- LOCAL_DEV_MAX_TOTAL_MEMORY_MB: 1024,
52
- /** Minimum heap size for worker in MB */
53
- MIN_WORKER_HEAP_SIZE_MB: 128,
54
- /** Default heap size when unable to determine system memory */
55
- DEFAULT_WORKER_HEAP_SIZE_MB: 512,
56
- };
57
- /**
58
- * Detects if the current environment is AWS Lambda.
59
- * @returns true if running in AWS Lambda
60
- */
61
- function isLambdaEnvironment() {
62
- return !!(process.env.AWS_LAMBDA_FUNCTION_NAME ||
63
- process.env.AWS_EXECUTION_ENV ||
64
- process.env.LAMBDA_TASK_ROOT);
65
- }
66
- /**
67
- * Gets the AWS Lambda memory limit from environment variable.
68
- * @returns Lambda memory limit in MB, or null if not in Lambda
69
- */
70
- function getLambdaMemoryLimitMb() {
71
- const memorySize = process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE;
72
- if (memorySize) {
73
- const parsed = parseInt(memorySize, 10);
74
- if (!isNaN(parsed) && parsed > 0) {
75
- return parsed;
76
- }
77
- }
78
- return null;
79
- }
80
- /**
81
- * Gets the total available memory based on the environment.
82
- * For Lambda: Uses AWS_LAMBDA_FUNCTION_MEMORY_SIZE
83
- * For local development: Caps at LOCAL_DEV_MAX_TOTAL_MEMORY_MB
84
- * For other environments: Uses system total memory or V8 heap limit
85
- *
86
- * @param isLocalDevelopment - Whether running in local development mode
87
- * @returns Total available memory in MB
88
- */
89
- function getTotalAvailableMemoryMb(isLocalDevelopment) {
90
- // For Lambda, use the configured memory limit
91
- const lambdaMemory = getLambdaMemoryLimitMb();
92
- if (lambdaMemory !== null) {
93
- return lambdaMemory;
94
- }
95
- // For local development, cap at LOCAL_DEV_MAX_TOTAL_MEMORY_MB
96
- if (isLocalDevelopment) {
97
- const systemMemoryMb = os.totalmem() / (1024 * 1024);
98
- return Math.min(systemMemoryMb, exports.MEMORY_CONSTANTS.LOCAL_DEV_MAX_TOTAL_MEMORY_MB);
99
- }
100
- // For other environments, use the smaller of system memory or V8 heap limit
101
- const systemMemoryMb = os.totalmem() / (1024 * 1024);
102
- const heapStats = v8.getHeapStatistics();
103
- const heapLimitMb = heapStats.heap_size_limit / (1024 * 1024);
104
- return Math.min(systemMemoryMb, heapLimitMb);
105
- }
106
- /**
107
- * Calculates the worker memory configuration based on the environment.
108
- *
109
- * @param isLocalDevelopment - Whether running in local development mode
110
- * @returns Worker memory configuration
111
- */
112
- function calculateWorkerMemoryConfig(isLocalDevelopment = false) {
113
- const isLambda = isLambdaEnvironment();
114
- const totalAvailableMemoryMb = getTotalAvailableMemoryMb(isLocalDevelopment);
115
- const workerMemoryPercentage = exports.MEMORY_CONSTANTS.WORKER_MEMORY_PERCENTAGE;
116
- // Calculate worker heap size (75-80% of total available)
117
- let maxOldGenerationSizeMb = Math.floor(totalAvailableMemoryMb * workerMemoryPercentage);
118
- // Ensure minimum heap size
119
- maxOldGenerationSizeMb = Math.max(maxOldGenerationSizeMb, exports.MEMORY_CONSTANTS.MIN_WORKER_HEAP_SIZE_MB);
120
- return {
121
- maxOldGenerationSizeMb,
122
- totalAvailableMemoryMb,
123
- isLambda,
124
- isLocalDevelopment,
125
- workerMemoryPercentage,
126
- };
127
- }
128
- /**
129
- * Node.js error code for worker thread OOM.
130
- * @see https://nodejs.org/api/errors.html#err_worker_out_of_memory
131
- */
132
- exports.ERR_WORKER_OUT_OF_MEMORY = 'ERR_WORKER_OUT_OF_MEMORY';
133
- /**
134
- * Regex patterns to detect OOM errors from error messages.
135
- * Used as a fallback when the error code is not available.
136
- */
137
- const OOM_MESSAGE_PATTERNS = [
138
- /JavaScript heap out of memory/i,
139
- /JS heap out of memory/i,
140
- /FATAL ERROR: .* out of memory/i,
141
- /Allocation failed - JavaScript heap out of memory/i,
142
- /FATAL ERROR: Reached heap limit/i,
143
- /FATAL ERROR: CALL_AND_RETRY_LAST/i,
144
- /memory allocation failed/i,
145
- /Worker terminated due to reaching memory limit/i,
146
- ];
147
- /**
148
- * Checks if an error indicates an OOM (Out-Of-Memory) error.
149
- *
150
- * This function first checks for the Node.js error code `ERR_WORKER_OUT_OF_MEMORY`
151
- * which is the standard way to detect worker thread OOM errors.
152
- * Falls back to regex pattern matching on the error message for other OOM scenarios.
153
- *
154
- * @param error - The error to check (can be an Error object or string message)
155
- * @returns true if the error indicates OOM
156
- * @see https://nodejs.org/api/errors.html#err_worker_out_of_memory
157
- */
158
- function isOOMError(error) {
159
- // If it's an Error object, check the code property first
160
- if (error instanceof Error) {
161
- // Node.js worker thread OOM errors have this code
162
- if (error.code === exports.ERR_WORKER_OUT_OF_MEMORY) {
163
- return true;
164
- }
165
- // Fall back to checking the message
166
- return OOM_MESSAGE_PATTERNS.some((pattern) => pattern.test(error.message));
167
- }
168
- // If it's a string, check against patterns (including the error code as a string)
169
- if (typeof error === 'string') {
170
- // Check if the string contains the error code
171
- if (error.includes(exports.ERR_WORKER_OUT_OF_MEMORY)) {
172
- return true;
173
- }
174
- return OOM_MESSAGE_PATTERNS.some((pattern) => pattern.test(error));
175
- }
176
- return false;
177
- }
@@ -1,11 +0,0 @@
1
- import { AirdropEvent } from '../../index';
2
- /**
3
- * Run extraction with OOM-specific options.
4
- * Uses a very small memory limit to trigger OOM quickly.
5
- */
6
- declare const run: (events: AirdropEvent[], workerPath: string, options?: {
7
- enableMemoryLimits?: boolean;
8
- testMemoryLimitMb?: number;
9
- }) => Promise<void>;
10
- export default run;
11
- //# sourceMappingURL=extraction.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extraction.d.ts","sourceRoot":"","sources":["../../../src/tests/oom-handling/extraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAS,MAAM,aAAa,CAAC;AAOlD;;;GAGG;AACH,QAAA,MAAM,GAAG,GACP,QAAQ,YAAY,EAAE,EACtB,YAAY,MAAM,EAClB,UAAU;IACR,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,kBAkBF,CAAC;AAEF,eAAe,GAAG,CAAC"}
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_1 = require("../../index");
4
- const initialState = {};
5
- const initialDomainMapping = {};
6
- /**
7
- * Run extraction with OOM-specific options.
8
- * Uses a very small memory limit to trigger OOM quickly.
9
- */
10
- const run = async (events, workerPath, options) => {
11
- var _a, _b;
12
- for (const event of events) {
13
- await (0, index_1.spawn)({
14
- event,
15
- initialState,
16
- workerPath,
17
- initialDomainMapping,
18
- options: {
19
- batchSize: 1000,
20
- timeout: 60 * 1000, // 60 seconds - enough time for OOM to occur
21
- isLocalDevelopment: true,
22
- enableMemoryLimits: (_a = options === null || options === void 0 ? void 0 : options.enableMemoryLimits) !== null && _a !== void 0 ? _a : true,
23
- // Use a small memory limit for testing (64MB) to trigger OOM quickly
24
- testMemoryLimitMb: (_b = options === null || options === void 0 ? void 0 : options.testMemoryLimitMb) !== null && _b !== void 0 ? _b : 64,
25
- },
26
- });
27
- }
28
- };
29
- exports.default = run;
@@ -1,7 +0,0 @@
1
- /**
2
- * Jest setup file for OOM handling tests.
3
- *
4
- * These tests intentionally trigger out-of-memory conditions to test
5
- * OOM detection and handling. This setup ensures proper cleanup between tests.
6
- */
7
- //# sourceMappingURL=jest.setup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jest.setup.d.ts","sourceRoot":"","sources":["../../../src/tests/oom-handling/jest.setup.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -1,26 +0,0 @@
1
- "use strict";
2
- /**
3
- * Jest setup file for OOM handling tests.
4
- *
5
- * These tests intentionally trigger out-of-memory conditions to test
6
- * OOM detection and handling. This setup ensures proper cleanup between tests.
7
- */
8
- // Force garbage collection between tests if available
9
- // This helps prevent memory accumulation across test cases
10
- afterEach(() => {
11
- // Clear any module caches that might retain memory
12
- jest.clearAllMocks();
13
- jest.resetModules();
14
- // Force garbage collection if available (Node.js must be run with --expose-gc)
15
- if (global.gc) {
16
- global.gc();
17
- }
18
- });
19
- afterAll(() => {
20
- // Final cleanup after all OOM tests complete
21
- jest.clearAllMocks();
22
- jest.resetModules();
23
- if (global.gc) {
24
- global.gc();
25
- }
26
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=oom-after-emit-worker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"oom-after-emit-worker.d.ts","sourceRoot":"","sources":["../../../src/tests/oom-handling/oom-after-emit-worker.ts"],"names":[],"mappings":""}
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_1 = require("../../index");
4
- /**
5
- * Worker that emits an event before causing an OOM error.
6
- * This tests the edge case where alreadyEmitted is true when OOM occurs.
7
- */
8
- (0, index_1.processTask)({
9
- task: async ({ adapter }) => {
10
- console.log('OOM after emit worker - emitting progress first');
11
- // Emit a progress event BEFORE causing OOM
12
- await adapter.emit(index_1.ExtractorEventType.DataExtractionProgress);
13
- console.log('Progress emitted successfully, waiting a moment...');
14
- // Wait a bit to ensure the emit was fully processed
15
- await new Promise((resolve) => setTimeout(resolve, 100));
16
- console.log('Now causing OOM...');
17
- // Array to hold references to prevent garbage collection
18
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
- const memoryHog = [];
20
- // Allocate memory until OOM
21
- while (true) {
22
- const chunk = [];
23
- for (let i = 0; i < 10000; i++) {
24
- chunk.push({
25
- data: 'x'.repeat(100),
26
- index: i,
27
- });
28
- }
29
- memoryHog.push(chunk);
30
- }
31
- },
32
- onTimeout: async ({ adapter }) => {
33
- await adapter.emit(index_1.ExtractorEventType.DataExtractionProgress);
34
- },
35
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=oom-attachments-worker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"oom-attachments-worker.d.ts","sourceRoot":"","sources":["../../../src/tests/oom-handling/oom-attachments-worker.ts"],"names":[],"mappings":""}
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_1 = require("../../index");
4
- /* eslint-disable @typescript-eslint/require-await */
5
- /* eslint-disable @typescript-eslint/no-unused-vars */
6
- /**
7
- * Worker that causes OOM during attachments extraction.
8
- * Tests OOM handling for EventType.StartExtractingAttachments.
9
- */
10
- (0, index_1.processTask)({
11
- task: async ({ adapter }) => {
12
- console.log('OOM attachments worker starting');
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- const memoryHog = [];
15
- while (true) {
16
- const chunk = [];
17
- for (let i = 0; i < 10000; i++) {
18
- chunk.push({
19
- data: 'attachment'.repeat(10),
20
- index: i,
21
- });
22
- }
23
- memoryHog.push(chunk);
24
- }
25
- },
26
- onTimeout: async ({ adapter }) => {
27
- await adapter.emit(index_1.ExtractorEventType.AttachmentExtractionProgress);
28
- },
29
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=oom-external-sync-units-worker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"oom-external-sync-units-worker.d.ts","sourceRoot":"","sources":["../../../src/tests/oom-handling/oom-external-sync-units-worker.ts"],"names":[],"mappings":""}
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_1 = require("../../index");
4
- /* eslint-disable @typescript-eslint/require-await */
5
- /* eslint-disable @typescript-eslint/no-unused-vars */
6
- /**
7
- * Worker that causes OOM during external sync units extraction.
8
- * Tests OOM handling for EventType.StartExtractingExternalSyncUnits.
9
- */
10
- (0, index_1.processTask)({
11
- task: async ({ adapter }) => {
12
- console.log('OOM external sync units worker starting');
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- const memoryHog = [];
15
- while (true) {
16
- const chunk = [];
17
- for (let i = 0; i < 10000; i++) {
18
- chunk.push({
19
- data: 'sync_unit'.repeat(11),
20
- index: i,
21
- });
22
- }
23
- memoryHog.push(chunk);
24
- }
25
- },
26
- onTimeout: async ({ adapter }) => {
27
- await adapter.emit(index_1.ExtractorEventType.ExternalSyncUnitExtractionDone);
28
- },
29
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=oom-gradual-worker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"oom-gradual-worker.d.ts","sourceRoot":"","sources":["../../../src/tests/oom-handling/oom-gradual-worker.ts"],"names":[],"mappings":""}
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_1 = require("../../index");
4
- /**
5
- * Worker that gradually consumes memory to simulate a memory leak.
6
- * This is a more realistic OOM scenario than rapid allocation.
7
- */
8
- (0, index_1.processTask)({
9
- task: async ({ adapter }) => {
10
- console.log('Gradual OOM worker starting - simulating memory leak');
11
- // Array to hold references to prevent garbage collection
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- const memoryHog = [];
14
- let totalAllocated = 0;
15
- try {
16
- // Allocate memory gradually with delays to simulate real processing
17
- while (true) {
18
- // Simulate some work
19
- await new Promise((resolve) => setTimeout(resolve, 10));
20
- // Create smaller chunks to simulate gradual memory growth
21
- const chunk = [];
22
- for (let i = 0; i < 2000; i++) {
23
- chunk.push({
24
- data: 'leak'.repeat(50), // ~200 bytes per string
25
- timestamp: Date.now(),
26
- index: i,
27
- });
28
- }
29
- memoryHog.push(chunk);
30
- totalAllocated++;
31
- if (totalAllocated % 5 === 0) {
32
- console.log(`Gradual allocation: ~${totalAllocated * 0.4}MB consumed`);
33
- }
34
- }
35
- }
36
- catch (error) {
37
- console.error('Error during gradual memory allocation:', error);
38
- await adapter.emit(index_1.ExtractorEventType.DataExtractionError, {
39
- error: { message: 'Gradual memory allocation failed' },
40
- });
41
- }
42
- },
43
- onTimeout: async ({ adapter }) => {
44
- console.log('Gradual OOM worker timeout handler called');
45
- await adapter.emit(index_1.ExtractorEventType.DataExtractionProgress);
46
- },
47
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=oom-handling.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"oom-handling.test.d.ts","sourceRoot":"","sources":["../../../src/tests/oom-handling/oom-handling.test.ts"],"names":[],"mappings":""}