grafana / pyroscope-nodejs

Pyroscope NodeJS integration
Apache License 2.0
26 stars 18 forks source link

Contexts are not supported #85

Open ArcenIce opened 2 months ago

ArcenIce commented 2 months ago

Hi, When starting pyroscope on my nodejs app (using expressjs) I'm getting an error: Contexts are not supported:

uncaughtException: Contexts are not supported.
TypeError: Contexts are not supported.
    at Object.start (C:\Users\alovergne\Documents\GithubPerso\Jaily\src\back\node_modules\@datadog\pprof\out\src\time-profiler.js:61:17)
    at WallProfiler.start (C:\Users\alovergne\Documents\GithubPerso\Jaily\src\back\node_modules\@pyroscope\nodejs\dist\cjs\profilers\wall-profiler.js:47:26)
    at ContinuousProfiler.start (C:\Users\alovergne\Documents\GithubPerso\Jaily\src\back\node_modules\@pyroscope\nodejs\dist\cjs\profilers\continuous-profiler.js:28:23)
    at startWallProfiling (C:\Users\alovergne\Documents\GithubPerso\Jaily\src\back\node_modules\@pyroscope\nodejs\dist\cjs\index.js:42:58)
    at Object.start (C:\Users\alovergne\Documents\GithubPerso\Jaily\src\back\node_modules\@pyroscope\nodejs\dist\cjs\index.js:62:5)
    at Object.<anonymous> (C:\Users\alovergne\Documents\GithubPerso\Jaily\src\back\src\index.js:78:11)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12) {"date":"Wed May 29 2024 16:13:37 GMT+0200 (heure d’été d’Europe centrale)","error":{},"exception":true,"os":{"loadavg":[0,0,0],"uptime":25848.796},"process":{"argv":["C:\\Program Files\\nodejs\\node.exe","C:\\Users\\alovergne\\Documents\\GithubPerso\\Jaily\\src\\back\\src\\index.js"],"cwd":"C:\\Users\\alovergne\\Documents\\GithubPerso\\Jaily\\src\\back","execPath":"C:\\Program Files\\nodejs\\node.exe","gid":null,"memoryUsage":{"arrayBuffers":18264489,"external":20623267,"heapTotal":58728448,"heapUsed":38249744,"rss":81870848},"pid":23904,"uid":null,"version":"v20.14.0"},"stack":"TypeError: Contexts are not supported.\n    at Object.start (C:\\Users\\alovergne\\Documents\\GithubPerso\\Jaily\\src\\back\\node_modules\\@datadog\\pprof\\out\\src\\time-profiler.js:61:17)\n    at WallProfiler.start (C:\\Users\\alovergne\\Documents\\GithubPerso\\Jaily\\src\\back\\node_modules\\@pyroscope\\nodejs\\dist\\cjs\\profilers\\wall-profiler.js:47:26)\n    at ContinuousProfiler.start (C:\\Users\\alovergne\\Documents\\GithubPerso\\Jaily\\src\\back\\node_modules\\@pyroscope\\nodejs\\dist\\cjs\\profilers\\continuous-profiler.js:28:23)\n    at startWallProfiling (C:\\Users\\alovergne\\Documents\\GithubPerso\\Jaily\\src\\back\\node_modules\\@pyroscope\\nodejs\\dist\\cjs\\index.js:42:58)\n    at Object.start (C:\\Users\\alovergne\\Documents\\GithubPerso\\Jaily\\src\\back\\node_modules\\@pyroscope\\nodejs\\dist\\cjs\\index.js:62:5)\n    at Object.<anonymous> (C:\\Users\\alovergne\\Documents\\GithubPerso\\Jaily\\src\\back\\src\\index.js:78:11)\n    at Module._compile (node:internal/modules/cjs/loader:1358:14)\n    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)\n    at Module.load (node:internal/modules/cjs/loader:1208:32)\n    at Module._load (node:internal/modules/cjs/loader:1024:12)","trace":[{"column":17,"file":"C:\\Users\\alovergne\\Documents\\GithubPerso\\Jaily\\src\\back\\node_modules\\@datadog\\pprof\\out\\src\\time-profiler.js","function":"Object.start","line":61,"method":"start","native":false},{"column":26,"file":"C:\\Users\\alovergne\\Documents\\GithubPerso\\Jaily\\src\\back\\node_modules\\@pyroscope\\nodejs\\dist\\cjs\\profilers\\wall-profiler.js","function":"WallProfiler.start","line":47,"method":"start","native":false},{"column":23,"file":"C:\\Users\\alovergne\\Documents\\GithubPerso\\Jaily\\src\\back\\node_modules\\@pyroscope\\nodejs\\dist\\cjs\\profilers\\continuous-profiler.js","function":"ContinuousProfiler.start","line":28,"method":"start","native":false},{"column":58,"file":"C:\\Users\\alovergne\\Documents\\GithubPerso\\Jaily\\src\\back\\node_modules\\@pyroscope\\nodejs\\dist\\cjs\\index.js","function":"startWallProfiling","line":42,"method":null,"native":false},{"column":5,"file":"C:\\Users\\alovergne\\Documents\\GithubPerso\\Jaily\\src\\back\\node_modules\\@pyroscope\\nodejs\\dist\\cjs\\index.js","function":"Object.start","line":62,"method":"start","native":false},{"column":11,"file":"C:\\Users\\alovergne\\Documents\\GithubPerso\\Jaily\\src\\back\\src\\index.js","function":null,"line":78,"method":null,"native":false},{"column":14,"file":"node:internal/modules/cjs/loader","function":"Module._compile","line":1358,"method":"_compile","native":false},{"column":10,"file":"node:internal/modules/cjs/loader","function":"Module._extensions..js","line":1416,"method":".js","native":false},{"column":32,"file":"node:internal/modules/cjs/loader","function":"Module.load","line":1208,"method":"load","native":false},{"column":12,"file":"node:internal/modules/cjs/loader","function":"Module._load","line":1024,"method":"_load","native":false}]}

I tried many things like upgrading and downgrading my nodejs to different versions, but always the same problem. Tried letting only the piece of code from documentation which is this one, same error:

const Pyroscope = require('@pyroscope/nodejs');
Pyroscope.init({
  serverAddress: '',
  appName: '',
  basicAuthUser: '',
  basicAuthPassword: ''
});
Pyroscope.start();

Does someone have an idea ?

bryanhuhta commented 2 months ago

:wave: Can you share some more information?

ArcenIce commented 2 months ago

👋 Can you share some more information?

  • What NodeJS version are you running?
  • What version of @pyroscope/nodejsare you using?

Tried running node 20.14.0 / 21.7.3 / 22.2.0, none worked For the version of pyroscope, it's 0.3.11

bryanhuhta commented 2 months ago

I think our 0.3.9 or 0.3.10 release may have introduced a bug here. I need to do some more digging, but perhaps you could try 0.3.8 and see if that helps?

ArcenIce commented 2 months ago

I think our 0.3.9 or 0.3.10 release may have introduced a bug here. I need to do some more digging, but perhaps you could try 0.3.8 and see if that helps?

Thank you, sadly 0.3.8 throws the same error Also tested on a fresh project with only this module but no progress

bryanhuhta commented 2 months ago

I looked into this a bit more. Unfortunately, since switching to the DataDog Nodejs profiler (as of v0.3.0), we don't support Windows. The DataDog profiler technically works but since we merged https://github.com/grafana/pyroscope-nodejs/pull/19, we always use dynamic labeling, which is not supported on Windows.

I'll create a ticket to add Windows support and I'll update our docs to reflect supported operating systems. It's possible v0.2.9 might work for you, but that uses a version of the SDK that is much buggier.