Skip to content

Commit e7d3e05

Browse files
authored
Remove support for node 14 (#173)
1 parent bebf35b commit e7d3e05

File tree

7 files changed

+19
-61
lines changed

7 files changed

+19
-61
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
asan:
1111
strategy:
1212
matrix:
13-
version: [14, 16, 18, 20, 22]
13+
version: [16, 18, 20, 22]
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v3
@@ -23,7 +23,7 @@ jobs:
2323
valgrind:
2424
strategy:
2525
matrix:
26-
version: [14, 16, 18, 20, 22]
26+
version: [16, 18, 20, 22]
2727
runs-on: ubuntu-latest
2828
steps:
2929
- uses: actions/checkout@v3
@@ -40,7 +40,7 @@ jobs:
4040
target-name: 'dd_pprof' # target name in binding.gyp
4141
package-manager: 'npm' # npm or yarn
4242
cache: true # enable caching of dependencies based on lockfile
43-
min-node-version: 14
43+
min-node-version: 16
4444
skip: 'linux-arm linux-ia32' # skip building for these platforms
4545

4646
dev_publish:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
target-name: 'dd_pprof' # target name in binding.gyp
1313
package-manager: 'npm' # npm or yarn
1414
cache: true # enable caching of dependencies based on lockfile
15-
min-node-version: 14
15+
min-node-version: 16
1616
skip: 'linux-arm linux-ia32' # skip building for these platforms
1717

1818
publish:

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
[pprof][pprof-url] support for Node.js.
88

99
## Prerequisites
10-
1. Your application will need to be using Node.js 14 or greater.
10+
1. Your application will need to be using Node.js 16 or greater.
1111

12-
2. The `pprof` module has a native component that is used to collect profiles
12+
2. The `pprof` module has a native component that is used to collect profiles
1313
with v8's CPU and Heap profilers. You may need to install additional
1414
dependencies to build this module.
1515
* For Linux: `pprof` has prebuilt binaries available for Linux arm64/x64,
16-
Alpine Linux x64, macOS arm64/x64, windows x64 for Node 14/16/18/20.
16+
Alpine Linux x64, macOS arm64/x64, windows x64 for Node 16/18/20/22.
1717
No additional dependencies are required.
1818
* For other environments: on environments that `pprof` does not have
1919
prebuilt binaries for, the module
@@ -42,7 +42,7 @@ Install [`pprof`][npm-url] with `npm` or add to your `package.json`.
4242
1. Update code to collect and save a profile:
4343
```javascript
4444
const profile = await pprof.time.profile({
45-
durationMillis: 10000, // time in milliseconds for which to
45+
durationMillis: 10000, // time in milliseconds for which to
4646
// collect profile.
4747
});
4848
const buf = await pprof.encode(profile);
@@ -63,8 +63,8 @@ Install [`pprof`][npm-url] with `npm` or add to your `package.json`.
6363
node --require @datadog/pprof app.js
6464
```
6565

66-
2. A wall time profile for the job will be saved in
67-
`pprof-profile-${process.pid}.pb.gz`. View the profile with command line
66+
2. A wall time profile for the job will be saved in
67+
`pprof-profile-${process.pid}.pb.gz`. View the profile with command line
6868
[`pprof`][pprof-url]:
6969
```sh
7070
pprof -http=: pprof-profile-${process.pid}.pb.gz
@@ -79,10 +79,10 @@ Install [`pprof`][npm-url] with `npm` or add to your `package.json`.
7979
// The maximum stack depth for samples collected.
8080
const stackDepth = 64;
8181
82-
heap.start(intervalBytes, stackDepth);
82+
heap.start(intervalBytes, stackDepth);
8383
```
8484
2. Collect heap profiles:
85-
85+
8686
* Collecting and saving a profile in profile.proto format:
8787
```javascript
8888
const profile = await pprof.heap.profile();
@@ -96,11 +96,11 @@ Install [`pprof`][npm-url] with `npm` or add to your `package.json`.
9696
```sh
9797
pprof -http=: heap.pb.gz
9898
```
99-
99+
100100
* Collecting a heap profile with V8 allocation profile format:
101101
```javascript
102102
const profile = await pprof.heap.v8Profile();
103-
```
103+
```
104104

105105
[build-image]: https://github.com/Datadog/pprof-nodejs/actions/workflows/build.yml/badge.svg?branch=main
106106
[build-url]: https://github.com/Datadog/pprof-nodejs/actions/workflows/build.yml

bindings/profilers/wall.cc

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ WallProfiler::WallProfiler(std::chrono::microseconds samplingPeriod,
485485
// When starting a new profile, wait for one signal before and one signal
486486
// after to reduce the likelihood that race condition occurs and one code
487487
// event just after triggers the issue.
488-
detectV8Bug_ = NODE_MODULE_VERSION >= NODE_16_0_MODULE_VERSION;
489488
workaroundV8Bug_ = workaroundV8Bug && DD_WALL_USE_SIGPROF && detectV8Bug_;
490489
collectCpuTime_ = collectCpuTime && withContexts;
491490

@@ -751,11 +750,7 @@ NAN_METHOD(WallProfiler::Stop) {
751750
Nan::ObjectWrap::Unwrap<WallProfiler>(info.Holder());
752751

753752
v8::Local<v8::Value> profile;
754-
#if NODE_MODULE_VERSION < NODE_16_0_MODULE_VERSION
755-
auto err = wallProfiler->StopImplOld(restart, profile);
756-
#else
757753
auto err = wallProfiler->StopImpl(restart, profile);
758-
#endif
759754

760755
if (!err.success) {
761756
return Nan::ThrowTypeError(err.msg.c_str());
@@ -895,39 +890,6 @@ Result WallProfiler::StopImpl(bool restart, v8::Local<v8::Value>& profile) {
895890
return {};
896891
}
897892

898-
Result WallProfiler::StopImplOld(bool restart, v8::Local<v8::Value>& profile) {
899-
if (!started_) {
900-
return Result{"Stop called on not started profiler."};
901-
}
902-
903-
if (withContexts_ || workaroundV8Bug_) {
904-
SignalHandler::DecreaseUseCount();
905-
}
906-
auto v8_profile = cpuProfiler_->StopProfiling(
907-
Nan::New<String>(profileId_).ToLocalChecked());
908-
909-
if (withContexts_) {
910-
auto contextsByNode =
911-
GetContextsByNode(v8_profile, contexts_, startThreadCpuTime_);
912-
profile = TranslateTimeProfile(
913-
v8_profile, includeLines_, &contextsByNode, collectCpuTime_);
914-
} else {
915-
profile = TranslateTimeProfile(v8_profile, includeLines_);
916-
}
917-
contexts_.clear();
918-
v8_profile->Delete();
919-
Dispose(v8::Isolate::GetCurrent());
920-
921-
if (restart) {
922-
CreateV8CpuProfiler();
923-
profileId_ = StartInternal();
924-
} else {
925-
started_ = false;
926-
}
927-
928-
return {};
929-
}
930-
931893
NAN_MODULE_INIT(WallProfiler::Init) {
932894
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
933895
Local<String> className = Nan::New("TimeProfiler").ToLocalChecked();
@@ -972,9 +934,6 @@ NAN_MODULE_INIT(WallProfiler::Init) {
972934
.FromJust();
973935
}
974936

975-
// A new CPU profiler object will be created each time profiling is started
976-
// to work around https://bugs.chromium.org/p/v8/issues/detail?id=11051.
977-
// TODO: Fixed in v16. Delete this hack when deprecating v14.
978937
v8::CpuProfiler* WallProfiler::CreateV8CpuProfiler() {
979938
if (cpuProfiler_ == nullptr) {
980939
v8::Isolate* isolate = v8::Isolate::GetCurrent();

bindings/profilers/wall.hh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class WallProfiler : public Nan::ObjectWrap {
6565
bool withContexts_ = false;
6666
bool started_ = false;
6767
bool workaroundV8Bug_;
68-
bool detectV8Bug_;
68+
static inline constexpr bool detectV8Bug_ = true;
6969
bool collectCpuTime_;
7070
bool isMainThread_;
7171
int v8ProfilerStuckEventLoopDetected_ = 0;
@@ -122,7 +122,6 @@ class WallProfiler : public Nan::ObjectWrap {
122122
Result StartImpl();
123123
std::string StartInternal();
124124
Result StopImpl(bool restart, v8::Local<v8::Value>& profile);
125-
Result StopImplOld(bool restart, v8::Local<v8::Value>& profile);
126125

127126
CollectionMode collectionMode() {
128127
auto res = collectionMode_.load(std::memory_order_relaxed);

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
"devDependencies": {
4343
"@types/mocha": "^10.0.1",
44-
"@types/node": ">=14",
44+
"@types/node": ">=16",
4545
"@types/sinon": "^10.0.15",
4646
"@types/tmp": "^0.2.3",
4747
"@typescript-eslint/eslint-plugin": "^5.60.1",
@@ -82,6 +82,6 @@
8282
]
8383
},
8484
"engines": {
85-
"node": ">=14"
85+
"node": ">=16"
8686
}
8787
}

0 commit comments

Comments
 (0)