@datadog/pprof 6.0.0-pre-feccb73 → 6.0.0-pre-83708df

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 (77) hide show
  1. package/README.md +7 -3
  2. package/out/src/heap-profiler-bindings.d.ts +2 -2
  3. package/out/src/heap-profiler-bindings.js +3 -3
  4. package/out/src/heap-profiler-bindings.js.map +1 -1
  5. package/out/src/heap-profiler.d.ts +16 -4
  6. package/out/src/heap-profiler.js +29 -17
  7. package/out/src/heap-profiler.js.map +1 -1
  8. package/out/src/index.d.ts +1 -0
  9. package/out/src/index.js +1 -0
  10. package/out/src/index.js.map +1 -1
  11. package/out/src/profile-serializer.d.ts +2 -1
  12. package/out/src/profile-serializer.js +17 -9
  13. package/out/src/profile-serializer.js.map +1 -1
  14. package/out/src/sourcemapper/sourcemapper.d.ts +38 -7
  15. package/out/src/sourcemapper/sourcemapper.js +275 -78
  16. package/out/src/sourcemapper/sourcemapper.js.map +1 -1
  17. package/out/src/time-profiler.d.ts +7 -2
  18. package/out/src/time-profiler.js +48 -23
  19. package/out/src/time-profiler.js.map +1 -1
  20. package/out/src/v8-types.d.ts +3 -0
  21. package/package.json +14 -19
  22. package/prebuilds/darwin-arm64/node-108.node +0 -0
  23. package/prebuilds/darwin-arm64/node-111.node +0 -0
  24. package/prebuilds/darwin-arm64/node-115.node +0 -0
  25. package/prebuilds/darwin-arm64/node-120.node +0 -0
  26. package/prebuilds/darwin-arm64/node-127.node +0 -0
  27. package/prebuilds/darwin-arm64/node-131.node +0 -0
  28. package/prebuilds/darwin-arm64/node-137.node +0 -0
  29. package/prebuilds/darwin-arm64/node-141.node +0 -0
  30. package/prebuilds/darwin-x64/node-108.node +0 -0
  31. package/prebuilds/darwin-x64/node-111.node +0 -0
  32. package/prebuilds/darwin-x64/node-115.node +0 -0
  33. package/prebuilds/darwin-x64/node-120.node +0 -0
  34. package/prebuilds/darwin-x64/node-127.node +0 -0
  35. package/prebuilds/darwin-x64/node-131.node +0 -0
  36. package/prebuilds/darwin-x64/node-137.node +0 -0
  37. package/prebuilds/darwin-x64/node-141.node +0 -0
  38. package/prebuilds/linuxglibc-arm64/node-108.node +0 -0
  39. package/prebuilds/linuxglibc-arm64/node-111.node +0 -0
  40. package/prebuilds/linuxglibc-arm64/node-115.node +0 -0
  41. package/prebuilds/linuxglibc-arm64/node-120.node +0 -0
  42. package/prebuilds/linuxglibc-arm64/node-127.node +0 -0
  43. package/prebuilds/linuxglibc-arm64/node-131.node +0 -0
  44. package/prebuilds/linuxglibc-arm64/node-137.node +0 -0
  45. package/prebuilds/linuxglibc-arm64/node-141.node +0 -0
  46. package/prebuilds/linuxglibc-x64/node-108.node +0 -0
  47. package/prebuilds/linuxglibc-x64/node-111.node +0 -0
  48. package/prebuilds/linuxglibc-x64/node-115.node +0 -0
  49. package/prebuilds/linuxglibc-x64/node-120.node +0 -0
  50. package/prebuilds/linuxglibc-x64/node-127.node +0 -0
  51. package/prebuilds/linuxglibc-x64/node-131.node +0 -0
  52. package/prebuilds/linuxglibc-x64/node-137.node +0 -0
  53. package/prebuilds/linuxglibc-x64/node-141.node +0 -0
  54. package/prebuilds/linuxmusl-arm64/node-108.node +0 -0
  55. package/prebuilds/linuxmusl-arm64/node-111.node +0 -0
  56. package/prebuilds/linuxmusl-arm64/node-115.node +0 -0
  57. package/prebuilds/linuxmusl-arm64/node-120.node +0 -0
  58. package/prebuilds/linuxmusl-arm64/node-127.node +0 -0
  59. package/prebuilds/linuxmusl-arm64/node-131.node +0 -0
  60. package/prebuilds/linuxmusl-arm64/node-137.node +0 -0
  61. package/prebuilds/linuxmusl-arm64/node-141.node +0 -0
  62. package/prebuilds/linuxmusl-x64/node-108.node +0 -0
  63. package/prebuilds/linuxmusl-x64/node-111.node +0 -0
  64. package/prebuilds/linuxmusl-x64/node-115.node +0 -0
  65. package/prebuilds/linuxmusl-x64/node-120.node +0 -0
  66. package/prebuilds/linuxmusl-x64/node-127.node +0 -0
  67. package/prebuilds/linuxmusl-x64/node-131.node +0 -0
  68. package/prebuilds/linuxmusl-x64/node-137.node +0 -0
  69. package/prebuilds/linuxmusl-x64/node-141.node +0 -0
  70. package/prebuilds/win32-x64/node-108.node +0 -0
  71. package/prebuilds/win32-x64/node-111.node +0 -0
  72. package/prebuilds/win32-x64/node-115.node +0 -0
  73. package/prebuilds/win32-x64/node-120.node +0 -0
  74. package/prebuilds/win32-x64/node-127.node +0 -0
  75. package/prebuilds/win32-x64/node-131.node +0 -0
  76. package/prebuilds/win32-x64/node-137.node +0 -0
  77. package/prebuilds/win32-x64/node-141.node +0 -0
@@ -47,11 +47,10 @@ var __importStar = (this && this.__importStar) || (function () {
47
47
  return result;
48
48
  };
49
49
  })();
50
- var __importDefault = (this && this.__importDefault) || function (mod) {
51
- return (mod && mod.__esModule) ? mod : { "default": mod };
52
- };
53
50
  Object.defineProperty(exports, "__esModule", { value: true });
54
- exports.SourceMapper = void 0;
51
+ exports.SourceMapper = exports.ANNOTATION_TAIL_BYTES = void 0;
52
+ exports.extractSourceMappingURL = extractSourceMappingURL;
53
+ exports.readSourceMappingURL = readSourceMappingURL;
55
54
  // Originally copied from cloud-debug-nodejs's sourcemapper.ts from
56
55
  // https://github.com/googleapis/cloud-debug-nodejs/blob/7bdc2f1f62a3b45b7b53ea79f9444c8ed50e138b/src/agent/io/sourcemapper.ts
57
56
  // Modified to map from generated code to source code, rather than from source
@@ -60,10 +59,115 @@ const fs = __importStar(require("fs"));
60
59
  const path = __importStar(require("path"));
61
60
  const sourceMap = __importStar(require("source-map"));
62
61
  const logger_1 = require("../logger");
63
- const p_limit_1 = __importDefault(require("p-limit"));
64
62
  const readFile = fs.promises.readFile;
65
63
  const CONCURRENCY = 10;
64
+ function createLimiter(concurrency) {
65
+ let active = 0;
66
+ const queue = [];
67
+ return function limit(fn) {
68
+ return new Promise((resolve, reject) => {
69
+ const run = () => {
70
+ active++;
71
+ fn()
72
+ .then(resolve, reject)
73
+ .finally(() => {
74
+ active--;
75
+ if (queue.length > 0)
76
+ queue.shift()();
77
+ });
78
+ };
79
+ if (active < concurrency)
80
+ run();
81
+ else
82
+ queue.push(run);
83
+ });
84
+ };
85
+ }
66
86
  const MAP_EXT = '.map';
87
+ // Per TC39 ECMA-426 §11.1.2.1 JavaScriptExtractSourceMapURL (without parsing):
88
+ // https://tc39.es/ecma426/#sec-linking-inline
89
+ //
90
+ // Split on these line terminators (ECMA-262 LineTerminatorSequence):
91
+ const LINE_SPLIT_RE = /\r\n|\n|\r|\u2028|\u2029/;
92
+ // Bytes to read from the end of a JS file when scanning for the annotation.
93
+ // The annotation must be on the last non-empty line, which is always short
94
+ // for external URLs. If no line terminator appears in the tail we fall back
95
+ // to a full file read (handles very large inline data: maps).
96
+ exports.ANNOTATION_TAIL_BYTES = 4 * 1024;
97
+ // Quote code points that invalidate the annotation (U+0022, U+0027, U+0060):
98
+ const QUOTE_CHARS_RE = /["'`]/;
99
+ // MatchSourceMapURL pattern applied to the comment text that follows "//":
100
+ const MATCH_SOURCE_MAP_URL_RE = /^[@#]\s*sourceMappingURL=(\S*?)\s*$/;
101
+ /**
102
+ * Extracts a sourceMappingURL from JS source per ECMA-426 §11.1.2.1
103
+ * (without-parsing variant).
104
+ *
105
+ * Scans lines from the end, skipping empty/whitespace-only lines.
106
+ * Returns null as soon as the first non-empty line is found that does not
107
+ * carry a valid annotation — the URL must be on the last non-empty line.
108
+ */
109
+ function extractSourceMappingURL(content) {
110
+ const lines = content.split(LINE_SPLIT_RE);
111
+ for (let i = lines.length - 1; i >= 0; i--) {
112
+ const line = lines[i];
113
+ if (line.trim() === '')
114
+ continue; // skip empty / whitespace-only lines
115
+ // This is the last non-empty line; it must carry the annotation or we stop.
116
+ const commentStart = line.indexOf('//');
117
+ if (commentStart === -1)
118
+ return undefined;
119
+ const comment = line.slice(commentStart + 2);
120
+ if (QUOTE_CHARS_RE.test(comment))
121
+ return undefined;
122
+ const match = MATCH_SOURCE_MAP_URL_RE.exec(comment);
123
+ return match ? match[1] || undefined : undefined;
124
+ }
125
+ return undefined;
126
+ }
127
+ /**
128
+ * Reads the sourceMappingURL from a JS file efficiently by only reading a
129
+ * small tail of the file.
130
+ *
131
+ * The annotation must be on the last non-empty line (ECMA-426), so as long as
132
+ * the tail contains at least one line terminator the last line is fully
133
+ * captured. If no line terminator appears in the tail the entire tail is part
134
+ * of one very long inline data: line; we fall back to a full file read in
135
+ * that case.
136
+ */
137
+ async function readSourceMappingURL(filePath) {
138
+ const fd = await fs.promises.open(filePath, 'r');
139
+ try {
140
+ const { size } = await fd.stat();
141
+ if (size === 0)
142
+ return undefined;
143
+ const tailSize = Math.min(exports.ANNOTATION_TAIL_BYTES, size);
144
+ const buf = Buffer.allocUnsafe(tailSize);
145
+ await fd.read(buf, 0, tailSize, size - tailSize);
146
+ const tail = buf.toString('utf8');
147
+ // The last non-empty line is fully captured in the tail if and only if a
148
+ // line terminator that precedes it also falls within the tail — i.e. the
149
+ // last non-empty segment is not the very first element of the split result.
150
+ //
151
+ // Counter-example: a large inline map followed by trailing empty lines.
152
+ // The tail might be "<end of base64>\n\n", which contains line terminators
153
+ // but whose last non-empty content ("<end of base64>") is the first
154
+ // segment — it extends before the window. Checking LINE_TERM_RE alone
155
+ // would incorrectly accept this tail.
156
+ const lines = tail.split(LINE_SPLIT_RE);
157
+ let lastNonEmptyIdx = lines.length - 1;
158
+ while (lastNonEmptyIdx > 0 && lines[lastNonEmptyIdx].trim() === '') {
159
+ lastNonEmptyIdx--;
160
+ }
161
+ if (tailSize === size || lastNonEmptyIdx > 0) {
162
+ return extractSourceMappingURL(tail);
163
+ }
164
+ const fullContent = await readFile(filePath, 'utf8');
165
+ return extractSourceMappingURL(fullContent);
166
+ }
167
+ finally {
168
+ await fd.close();
169
+ }
170
+ }
67
171
  function error(msg) {
68
172
  logger_1.logger.debug(`Error: ${msg}`);
69
173
  return new Error(msg);
@@ -89,23 +193,6 @@ async function processSourceMap(infoMap, mapPath, debug) {
89
193
  catch (e) {
90
194
  throw error('Could not read source map file ' + mapPath + ': ' + e);
91
195
  }
92
- let consumer;
93
- try {
94
- // TODO: Determine how to reconsile the type conflict where `consumer`
95
- // is constructed as a SourceMapConsumer but is used as a
96
- // RawSourceMap.
97
- // TODO: Resolve the cast of `contents as any` (This is needed because the
98
- // type is expected to be of `RawSourceMap` but the existing
99
- // working code uses a string.)
100
- consumer = (await new sourceMap.SourceMapConsumer(contents));
101
- }
102
- catch (e) {
103
- throw error('An error occurred while reading the ' +
104
- 'sourceMap file ' +
105
- mapPath +
106
- ': ' +
107
- e);
108
- }
109
196
  /* If the source map file defines a "file" attribute, use it as
110
197
  * the output file where the path is relative to the directory
111
198
  * containing the map file. Otherwise, use the name of the output
@@ -123,67 +210,186 @@ async function processSourceMap(infoMap, mapPath, debug) {
123
210
  * source map file.
124
211
  */
125
212
  const dir = path.dirname(mapPath);
213
+ // Parse JSON once: extract the `file` property for early-exit checks and
214
+ // reuse the parsed object when constructing SourceMapConsumer (avoids a
215
+ // second parse inside the library).
216
+ let parsedMap;
217
+ let rawFile;
218
+ try {
219
+ parsedMap = JSON.parse(contents);
220
+ rawFile = parsedMap.file;
221
+ }
222
+ catch {
223
+ // Will fail again below when creating SourceMapConsumer; let that throw.
224
+ }
126
225
  const generatedPathCandidates = [];
127
- if (consumer.file) {
128
- generatedPathCandidates.push(path.resolve(dir, consumer.file));
226
+ if (rawFile) {
227
+ generatedPathCandidates.push(path.resolve(dir, rawFile));
129
228
  }
130
229
  const samePath = path.resolve(dir, path.basename(mapPath, MAP_EXT));
131
230
  if (generatedPathCandidates.length === 0 ||
132
231
  generatedPathCandidates[0] !== samePath) {
133
232
  generatedPathCandidates.push(samePath);
134
233
  }
135
- for (const generatedPath of generatedPathCandidates) {
136
- try {
137
- await fs.promises.access(generatedPath, fs.constants.F_OK);
138
- infoMap.set(generatedPath, { mapFileDir: dir, mapConsumer: consumer });
234
+ // Find the first candidate that exists and hasn't been loaded already.
235
+ let targetPath;
236
+ for (const candidate of generatedPathCandidates) {
237
+ if (infoMap.has(candidate)) {
238
+ // Already loaded via sourceMappingURL annotation; skip this map file.
139
239
  if (debug) {
140
- logger_1.logger.debug(`Loaded source map for ${generatedPath} => ${mapPath}`);
240
+ logger_1.logger.debug(`Skipping ${mapPath}: ${candidate} already loaded via sourceMappingURL`);
141
241
  }
142
242
  return;
143
243
  }
144
- catch (err) {
244
+ try {
245
+ await fs.promises.access(candidate, fs.constants.F_OK);
246
+ targetPath = candidate;
247
+ break;
248
+ }
249
+ catch {
145
250
  if (debug) {
146
- logger_1.logger.debug(`Generated path ${generatedPath} does not exist`);
251
+ logger_1.logger.debug(`Generated path ${candidate} does not exist`);
147
252
  }
148
253
  }
149
254
  }
255
+ if (!targetPath) {
256
+ if (debug) {
257
+ logger_1.logger.debug(`Unable to find generated file for ${mapPath}`);
258
+ }
259
+ return;
260
+ }
261
+ let consumer;
262
+ try {
263
+ // TODO: Determine how to reconsile the type conflict where `consumer`
264
+ // is constructed as a SourceMapConsumer but is used as a
265
+ // RawSourceMap.
266
+ consumer = (await new sourceMap.SourceMapConsumer((parsedMap ?? contents)));
267
+ }
268
+ catch (e) {
269
+ throw error('An error occurred while reading the ' +
270
+ 'sourceMap file ' +
271
+ mapPath +
272
+ ': ' +
273
+ e);
274
+ }
275
+ infoMap.set(targetPath, { mapFileDir: dir, mapConsumer: consumer });
150
276
  if (debug) {
151
- logger_1.logger.debug(`Unable to find generated file for ${mapPath}`);
277
+ logger_1.logger.debug(`Loaded source map for ${targetPath} => ${mapPath}`);
152
278
  }
153
279
  }
154
280
  class SourceMapper {
155
281
  static async create(searchDirs, debug = false) {
156
- if (debug) {
157
- logger_1.logger.debug(`Looking for source map files in dirs: [${searchDirs.join(', ')}]`);
282
+ const mapper = new SourceMapper(debug);
283
+ for (const dir of searchDirs) {
284
+ await mapper.loadDirectory(dir);
158
285
  }
286
+ return mapper;
287
+ }
288
+ constructor(debug = false) {
289
+ /** JS files that declared a sourceMappingURL but no map was ultimately found. */
290
+ this.declaredMissingMap = new Set();
291
+ this.infoMap = new Map();
292
+ this.debug = debug;
293
+ }
294
+ /**
295
+ * Scans `searchDir` recursively for JS files and source map files, loading
296
+ * source maps for all JS files found.
297
+ *
298
+ * Priority for each JS file:
299
+ * 1. A map pointed to by a `sourceMappingURL` annotation in the JS file
300
+ * (inline `data:` URL or external file path, only if the file exists).
301
+ * 2. A `.map` file found in the directory scan that claims to belong to
302
+ * that JS file (via its `file` property or naming convention).
303
+ *
304
+ * Safe to call multiple times; already-loaded files are skipped.
305
+ */
306
+ async loadDirectory(searchDir) {
307
+ // Resolve to absolute so all paths in infoMap are consistent regardless of
308
+ // whether the caller passed a relative or absolute directory.
309
+ searchDir = path.resolve(searchDir);
310
+ if (this.debug) {
311
+ logger_1.logger.debug(`Loading source maps from directory: ${searchDir}`);
312
+ }
313
+ const jsFiles = [];
159
314
  const mapFiles = [];
160
- for (const dir of searchDirs) {
161
- try {
162
- const mf = await getMapFiles(dir);
163
- mf.forEach(mapFile => {
164
- mapFiles.push(path.resolve(dir, mapFile));
165
- });
315
+ for await (const entry of walk(searchDir, filename => /\.[cm]?js$/.test(filename) || /\.[cm]?js\.map$/.test(filename), (root, dirname) => root !== '/proc' && dirname !== '.git' && dirname !== 'node_modules')) {
316
+ if (entry.endsWith(MAP_EXT)) {
317
+ mapFiles.push(entry);
166
318
  }
167
- catch (e) {
168
- throw error(`failed to get source maps from ${dir}: ${e}`);
319
+ else {
320
+ jsFiles.push(entry);
169
321
  }
170
322
  }
171
- if (debug) {
172
- logger_1.logger.debug(`Found source map files: [${mapFiles.join(', ')}]`);
323
+ if (this.debug) {
324
+ logger_1.logger.debug(`Found ${jsFiles.length} JS files and ${mapFiles.length} map files in ${searchDir}`);
325
+ }
326
+ const limit = createLimiter(CONCURRENCY);
327
+ // JS files that declared a sourceMappingURL but Phase 1 couldn't load the map.
328
+ const annotatedNotLoaded = new Set();
329
+ // Phase 1: Check sourceMappingURL annotations in JS files (higher priority).
330
+ await Promise.all(jsFiles.map(jsPath => limit(async () => {
331
+ if (this.infoMap.has(jsPath))
332
+ return;
333
+ let url;
334
+ try {
335
+ url = await readSourceMappingURL(jsPath);
336
+ }
337
+ catch {
338
+ return;
339
+ }
340
+ if (!url)
341
+ return;
342
+ if (url.startsWith('data:')) {
343
+ // Inline source map data URL. Handles both:
344
+ // data:application/json;base64,<b64>
345
+ // data:application/json;charset=utf-8;base64,<b64>
346
+ // data:application/json,<urlencoded> (and other non-base64 forms)
347
+ const commaIdx = url.indexOf(',');
348
+ if (commaIdx !== -1) {
349
+ const meta = url.slice(0, commaIdx);
350
+ const data = url.slice(commaIdx + 1);
351
+ const mapContent = meta.endsWith(';base64')
352
+ ? Buffer.from(data, 'base64').toString()
353
+ : decodeURIComponent(data);
354
+ await this.loadMapContent(jsPath, mapContent, path.dirname(jsPath));
355
+ }
356
+ // If the data URL is malformed (no comma), skip silently — not a
357
+ // missing map file, just an unreadable inline annotation.
358
+ }
359
+ else {
360
+ const mapPath = path.resolve(path.dirname(jsPath), url);
361
+ try {
362
+ const mapContent = await readFile(mapPath, 'utf8');
363
+ await this.loadMapContent(jsPath, mapContent, path.dirname(mapPath));
364
+ }
365
+ catch {
366
+ // Map file doesn't exist or is unreadable; fall through to Phase 2.
367
+ annotatedNotLoaded.add(jsPath);
368
+ }
369
+ }
370
+ })));
371
+ // Phase 2: Process .map files for any JS files not yet resolved.
372
+ await Promise.all(mapFiles.map(mapPath => limit(() => processSourceMap(this.infoMap, mapPath, this.debug))));
373
+ // Any file whose annotation pointed to a missing map and that still has no
374
+ // entry after Phase 2 is tracked as "declared but missing".
375
+ for (const jsPath of annotatedNotLoaded) {
376
+ if (!this.infoMap.has(jsPath)) {
377
+ this.declaredMissingMap.add(jsPath);
378
+ }
173
379
  }
174
- return createFromMapFiles(mapFiles, debug);
175
380
  }
176
- /**
177
- * @param {Array.<string>} sourceMapPaths An array of paths to .map source map
178
- * files that should be processed. The paths should be relative to the
179
- * current process's current working directory
180
- * @param {Logger} logger A logger that reports errors that occurred while
181
- * processing the given source map files
182
- * @constructor
183
- */
184
- constructor(debug = false) {
185
- this.infoMap = new Map();
186
- this.debug = debug;
381
+ async loadMapContent(jsPath, mapContent, mapDir) {
382
+ try {
383
+ const parsedMap = JSON.parse(mapContent);
384
+ const consumer = (await new sourceMap.SourceMapConsumer(parsedMap));
385
+ this.infoMap.set(jsPath, { mapFileDir: mapDir, mapConsumer: consumer });
386
+ if (this.debug) {
387
+ logger_1.logger.debug(`Loaded source map for ${jsPath} via sourceMappingURL`);
388
+ }
389
+ }
390
+ catch (e) {
391
+ logger_1.logger.debug(`Failed to parse source map for ${jsPath}: ${e}`);
392
+ }
187
393
  }
188
394
  /**
189
395
  * Used to get the information about the transpiled file from a given input
@@ -197,8 +403,9 @@ class SourceMapper {
197
403
  * could possibly be associated with the given input path.
198
404
  */
199
405
  getMappingInfo(inputPath) {
200
- if (this.infoMap.has(path.normalize(inputPath))) {
201
- return this.infoMap.get(inputPath);
406
+ const normalizedPath = path.normalize(inputPath);
407
+ if (this.infoMap.has(normalizedPath)) {
408
+ return this.infoMap.get(normalizedPath);
202
409
  }
203
410
  return null;
204
411
  }
@@ -244,6 +451,9 @@ class SourceMapper {
244
451
  if (this.debug) {
245
452
  logger_1.logger.debug(`Source map lookup failed: no map found for ${location.file} (normalized: ${inputPath})`);
246
453
  }
454
+ if (this.declaredMissingMap.has(inputPath)) {
455
+ return { ...location, missingMapFile: true };
456
+ }
247
457
  return location;
248
458
  }
249
459
  const generatedPos = {
@@ -252,7 +462,13 @@ class SourceMapper {
252
462
  };
253
463
  // TODO: Determine how to remove the explicit cast here.
254
464
  const consumer = entry.mapConsumer;
255
- const pos = consumer.originalPositionFor(generatedPos);
465
+ // When column is 0, we don't have real column info (e.g., from V8's LineTick
466
+ // which only provides line numbers). Use LEAST_UPPER_BOUND to find the first
467
+ // mapping on this line instead of failing because there's nothing at column 0.
468
+ const bias = generatedPos.column === 0
469
+ ? sourceMap.SourceMapConsumer.LEAST_UPPER_BOUND
470
+ : sourceMap.SourceMapConsumer.GREATEST_LOWER_BOUND;
471
+ const pos = consumer.originalPositionFor({ ...generatedPos, bias });
256
472
  if (pos.source === null) {
257
473
  if (this.debug) {
258
474
  logger_1.logger.debug(`Source map lookup failed for ${location.name}(${location.file}:${location.line}:${location.column})`);
@@ -272,18 +488,6 @@ class SourceMapper {
272
488
  }
273
489
  }
274
490
  exports.SourceMapper = SourceMapper;
275
- async function createFromMapFiles(mapFiles, debug) {
276
- const limit = (0, p_limit_1.default)(CONCURRENCY);
277
- const mapper = new SourceMapper(debug);
278
- const promises = mapFiles.map(mapPath => limit(() => processSourceMap(mapper.infoMap, mapPath, debug)));
279
- try {
280
- await Promise.all(promises);
281
- }
282
- catch (err) {
283
- throw error('An error occurred while processing the source map files' + err);
284
- }
285
- return mapper;
286
- }
287
491
  function isErrnoException(e) {
288
492
  return e instanceof Error && 'code' in e;
289
493
  }
@@ -321,11 +525,4 @@ directoryFilter = (root, dirname) => true) {
321
525
  }
322
526
  yield* walkRecursive(dir);
323
527
  }
324
- async function getMapFiles(baseDir) {
325
- const mapFiles = [];
326
- for await (const entry of walk(baseDir, filename => /\.[cm]?js\.map$/.test(filename), (root, dirname) => root !== '/proc' && dirname !== '.git' && dirname !== 'node_modules')) {
327
- mapFiles.push(path.relative(baseDir, entry));
328
- }
329
- return mapFiles;
330
- }
331
528
  //# sourceMappingURL=sourcemapper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sourcemapper.js","sourceRoot":"","sources":["../../../ts/src/sourcemapper/sourcemapper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,mEAAmE;AACnE,8HAA8H;AAC9H,8EAA8E;AAC9E,0BAA0B;AAE1B,uCAAyB;AACzB,2CAA6B;AAC7B,sDAAwC;AACxC,sCAAiC;AACjC,sDAA6B;AAE7B,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,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,CAAC;IAED,KAAK,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC"}
@@ -37,11 +37,16 @@ export interface TimeProfilerOptions {
37
37
  collectAsyncId?: boolean;
38
38
  useCPED?: boolean;
39
39
  }
40
- export declare function profile(options?: TimeProfilerOptions): Promise<import("pprof-format").Profile>;
40
+ export declare function profile(options?: TimeProfilerOptions): Promise<any>;
41
41
  export declare function start(options?: TimeProfilerOptions): void;
42
- export declare function stop(restart?: boolean, generateLabels?: GenerateTimeLabelsFunction, lowCardinalityLabels?: string[]): import("pprof-format").Profile;
42
+ /**
43
+ * Serializes the profile inside a native callback while the V8 profile is
44
+ * still alive. This reduces memory overhead.
45
+ */
46
+ export declare function stop(restart?: boolean, generateLabels?: GenerateTimeLabelsFunction, lowCardinalityLabels?: string[]): any;
43
47
  export declare function getState(): any;
44
48
  export declare function setContext(context?: object): void;
49
+ export declare function runWithContext<R, TArgs extends unknown[]>(context: object, f: (...args: TArgs) => R, ...args: TArgs): R;
45
50
  export declare function getContext(): any;
46
51
  export declare function getMetrics(): TimeProfilerMetrics;
47
52
  export declare function isStarted(): boolean;
@@ -14,9 +14,6 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
17
  Object.defineProperty(exports, "__esModule", { value: true });
21
18
  exports.getNativeThreadId = exports.constants = void 0;
22
19
  exports.profile = profile;
@@ -24,22 +21,49 @@ exports.start = start;
24
21
  exports.stop = stop;
25
22
  exports.getState = getState;
26
23
  exports.setContext = setContext;
24
+ exports.runWithContext = runWithContext;
27
25
  exports.getContext = getContext;
28
26
  exports.getMetrics = getMetrics;
29
27
  exports.isStarted = isStarted;
30
28
  exports.v8ProfilerStuckEventLoopDetected = v8ProfilerStuckEventLoopDetected;
31
- const delay_1 = __importDefault(require("delay"));
29
+ const promises_1 = require("timers/promises");
32
30
  const profile_serializer_1 = require("./profile-serializer");
33
31
  const time_profiler_bindings_1 = require("./time-profiler-bindings");
34
32
  Object.defineProperty(exports, "getNativeThreadId", { enumerable: true, get: function () { return time_profiler_bindings_1.getNativeThreadId; } });
35
33
  const worker_threads_1 = require("worker_threads");
34
+ const async_hooks_1 = require("async_hooks");
36
35
  const { kSampleCount } = time_profiler_bindings_1.constants;
37
36
  const DEFAULT_INTERVAL_MICROS = 1000;
38
37
  const DEFAULT_DURATION_MILLIS = 60000;
39
38
  let gProfiler;
39
+ let gStore;
40
40
  let gSourceMapper;
41
41
  let gIntervalMicros;
42
42
  let gV8ProfilerStuckEventLoopDetected = 0;
43
+ function handleStopRestart() {
44
+ if (!gProfiler) {
45
+ return;
46
+ }
47
+ gV8ProfilerStuckEventLoopDetected =
48
+ gProfiler.v8ProfilerStuckEventLoopDetected();
49
+ // Workaround for v8 bug, where profiler event processor thread is stuck in
50
+ // a loop eating 100% CPU, leading to empty profiles.
51
+ // Fully stop and restart the profiler to reset the profile to a valid state.
52
+ if (gV8ProfilerStuckEventLoopDetected > 0) {
53
+ gProfiler.stopAndCollect(false, () => undefined);
54
+ gProfiler.start();
55
+ }
56
+ }
57
+ function handleStopNoRestart() {
58
+ gV8ProfilerStuckEventLoopDetected = 0;
59
+ gProfiler?.dispose();
60
+ gProfiler = undefined;
61
+ gSourceMapper = undefined;
62
+ if (gStore !== undefined) {
63
+ gStore.disable();
64
+ gStore = undefined;
65
+ }
66
+ }
43
67
  /** Make sure to stop profiler before node shuts down, otherwise profiling
44
68
  * signal might cause a crash if it occurs during shutdown */
45
69
  process.once('exit', () => {
@@ -59,7 +83,7 @@ const DEFAULT_OPTIONS = {
59
83
  async function profile(options = {}) {
60
84
  options = { ...DEFAULT_OPTIONS, ...options };
61
85
  start(options);
62
- await (0, delay_1.default)(options.durationMillis);
86
+ await (0, promises_1.setTimeout)(options.durationMillis);
63
87
  return stop();
64
88
  }
65
89
  // Temporarily retained for backwards compatibility with older tracer
@@ -68,40 +92,32 @@ function start(options = {}) {
68
92
  if (gProfiler) {
69
93
  throw new Error('Wall profiler is already started');
70
94
  }
71
- gProfiler = new time_profiler_bindings_1.TimeProfiler({ ...options, isMainThread: worker_threads_1.isMainThread });
95
+ const store = options.useCPED === true ? new async_hooks_1.AsyncLocalStorage() : undefined;
96
+ gProfiler = new time_profiler_bindings_1.TimeProfiler({ ...options, CPEDKey: store, isMainThread: worker_threads_1.isMainThread });
72
97
  gSourceMapper = options.sourceMapper;
73
98
  gIntervalMicros = options.intervalMicros;
74
99
  gV8ProfilerStuckEventLoopDetected = 0;
75
100
  gProfiler.start();
101
+ gStore = store;
76
102
  // If contexts are enabled without using CPED, set an initial empty context
77
103
  if (options.withContexts && !options.useCPED) {
78
104
  setContext({});
79
105
  }
80
106
  }
107
+ /**
108
+ * Serializes the profile inside a native callback while the V8 profile is
109
+ * still alive. This reduces memory overhead.
110
+ */
81
111
  function stop(restart = false, generateLabels, lowCardinalityLabels) {
82
112
  if (!gProfiler) {
83
113
  throw new Error('Wall profiler is not started');
84
114
  }
85
- const profile = gProfiler.stop(restart);
115
+ const serializedProfile = gProfiler.stopAndCollect(restart, (profile) => (0, profile_serializer_1.serializeTimeProfile)(profile, gIntervalMicros, gSourceMapper, true, generateLabels, lowCardinalityLabels));
86
116
  if (restart) {
87
- gV8ProfilerStuckEventLoopDetected =
88
- gProfiler.v8ProfilerStuckEventLoopDetected();
89
- // Workaround for v8 bug, where profiler event processor thread is stuck in
90
- // a loop eating 100% CPU, leading to empty profiles.
91
- // Fully stop and restart the profiler to reset the profile to a valid state.
92
- if (gV8ProfilerStuckEventLoopDetected > 0) {
93
- gProfiler.stop(false);
94
- gProfiler.start();
95
- }
117
+ handleStopRestart();
96
118
  }
97
119
  else {
98
- gV8ProfilerStuckEventLoopDetected = 0;
99
- }
100
- const serializedProfile = (0, profile_serializer_1.serializeTimeProfile)(profile, gIntervalMicros, gSourceMapper, true, generateLabels, lowCardinalityLabels);
101
- if (!restart) {
102
- gProfiler.dispose();
103
- gProfiler = undefined;
104
- gSourceMapper = undefined;
120
+ handleStopNoRestart();
105
121
  }
106
122
  return serializedProfile;
107
123
  }
@@ -117,6 +133,15 @@ function setContext(context) {
117
133
  }
118
134
  gProfiler.context = context;
119
135
  }
136
+ function runWithContext(context, f, ...args) {
137
+ if (!gProfiler) {
138
+ throw new Error('Wall profiler is not started');
139
+ }
140
+ else if (!gStore) {
141
+ throw new Error('Can only use runWithContext with AsyncContextFrame');
142
+ }
143
+ return gStore.run(gProfiler.createContextHolder(context), f, ...args);
144
+ }
120
145
  function getContext() {
121
146
  if (!gProfiler) {
122
147
  throw new Error('Wall profiler is not started');