@platformatic/wattpm-pprof-capture 3.54.0 → 3.55.0

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 (2) hide show
  1. package/index.js +20 -3
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -6,6 +6,21 @@ import { SourceMapperWrapper } from './lib/source-mapper-wrapper.js'
6
6
 
7
7
  const kITC = Symbol.for('plt.runtime.itc')
8
8
 
9
+ // @datadog/pprof >= 5.14.2 introduced a regression in the legacy time profiler
10
+ // `stop()`: it now clears the internal source mapper (via handleStopNoRestart)
11
+ // *before* serializing the profile, so transpiled frames (e.g. TypeScript) are
12
+ // no longer mapped back to their original `.ts` sources. The `stopV2()` entry
13
+ // point serializes the profile while the source mapper is still set — the
14
+ // behaviour `stop()` had in earlier versions. It is not re-exported on the
15
+ // public `time` facade, so resolve it from the internal module when available
16
+ // and fall back to the public `stop()` otherwise (e.g. older versions).
17
+ let stopTimeProfilerV2 = null
18
+ try {
19
+ ;({ stopV2: stopTimeProfilerV2 } = await import('@datadog/pprof/out/src/time-profiler.js'))
20
+ } catch {
21
+ // Internal module path not available; fall back to the public stop().
22
+ }
23
+
9
24
  // SourceMapper for resolving transpiled code locations back to original source
10
25
  let sourceMapper = null
11
26
  let sourceMapperInitialized = false
@@ -159,9 +174,11 @@ function stopProfiler (type, state) {
159
174
  state.latestProfile = (state.sourceMapsEnabled && sourceMapper) ? profiler.profile(undefined, sourceMapper) : profiler.profile()
160
175
  profiler.stop()
161
176
  } else {
162
- // CPU time profiler returns the profile when stopping
163
- // sourceMapper was already passed to start(), so it's applied automatically
164
- state.latestProfile = profiler.stop()
177
+ // CPU time profiler returns the profile when stopping.
178
+ // sourceMapper was already passed to start(), so it's applied automatically.
179
+ // Use stopV2() when available so the source mapper is honoured during
180
+ // serialization (see the note next to stopTimeProfilerV2 above).
181
+ state.latestProfile = stopTimeProfilerV2 ? stopTimeProfilerV2() : profiler.stop()
165
182
  }
166
183
  }
167
184
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/wattpm-pprof-capture",
3
- "version": "3.54.0",
3
+ "version": "3.55.0",
4
4
  "description": "pprof profiling capture for wattpm",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,8 +26,8 @@
26
26
  "neostandard": "^0.12.0",
27
27
  "pprof-format": "^2.1.0",
28
28
  "typescript": "^5.0.0",
29
- "@platformatic/service": "3.54.0",
30
- "@platformatic/foundation": "3.54.0"
29
+ "@platformatic/foundation": "3.55.0",
30
+ "@platformatic/service": "3.55.0"
31
31
  },
32
32
  "engines": {
33
33
  "node": ">=22.19.0"