From 36e4ba3948ba533294c6f45442dcca33d9ce68de Mon Sep 17 00:00:00 2001 From: JonasBa Date: Fri, 13 Jan 2023 10:34:58 -0500 Subject: [PATCH 1/4] test(build): add node 19 to build matrix --- .github/workflows/build.yml | 2 +- .github/workflows/ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d3f94647..0ace80e5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-2019, ubuntu-latest] - node-version: [14.x, 16.x, 18.x] + node-version: [14.x, 16.x, 18.x, 19.x] target: [x64] host: [x64] # arm64 is not supported by gh runners yet diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e46d888..69cc9d51 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-2019, ubuntu-latest] - node-version: [14.x, 16.x, 18.x] + node-version: [14.x, 16.x, 18.x, 19.x] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 From 14322f648b7193f037350238a3d27d79bcace973 Mon Sep 17 00:00:00 2001 From: JonasBa Date: Fri, 13 Jan 2023 10:43:24 -0500 Subject: [PATCH 2/4] fix(bindings): remove constructor --- bindings/cpu_profiler.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bindings/cpu_profiler.cc b/bindings/cpu_profiler.cc index 1ea168c8..eb5b6287 100644 --- a/bindings/cpu_profiler.cc +++ b/bindings/cpu_profiler.cc @@ -279,12 +279,10 @@ static void StartProfiling(const v8::FunctionCallbackInfo& args) { v8::Local title = Nan::To(args[0]).ToLocalChecked(); - v8::CpuProfilingOptions options = v8::CpuProfilingOptions{ - v8::CpuProfilingMode::kCallerLineNumbers, v8::CpuProfilingOptions::kNoSampleLimit, - SAMPLING_INTERVAL_US }; - Profiler* profiler = reinterpret_cast(args.Data().As()->Value()); - profiler->cpu_profiler->StartProfiling(title, options); + profiler->cpu_profiler->StartProfiling(title, { + v8::CpuProfilingMode::kCallerLineNumbers, v8::CpuProfilingOptions::kNoSampleLimit, + SAMPLING_INTERVAL_US }); }; // StopProfiling(string title) From e08fdb1419cf1882cab0c44818b52db817bd29e2 Mon Sep 17 00:00:00 2001 From: JonasBa Date: Fri, 13 Jan 2023 10:52:54 -0500 Subject: [PATCH 3/4] test(hub): use legacy timers --- src/cpu_profiler.ts | 1 - src/hubextensions.hub.test.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cpu_profiler.ts b/src/cpu_profiler.ts index b69aa476..d2bd53e8 100644 --- a/src/cpu_profiler.ts +++ b/src/cpu_profiler.ts @@ -56,7 +56,6 @@ interface V8CpuProfilerBindings { stopProfiling(name: string): RawThreadCpuProfile | null; } -console.log(projectRootDirectory); const privateBindings: PrivateV8CpuProfilerBindings = importCppBindingsModule(); const CpuProfilerBindings: V8CpuProfilerBindings = { startProfiling(name: string) { diff --git a/src/hubextensions.hub.test.ts b/src/hubextensions.hub.test.ts index 2d9d2577..e83a62f4 100644 --- a/src/hubextensions.hub.test.ts +++ b/src/hubextensions.hub.test.ts @@ -47,7 +47,7 @@ describe('hubextensions', () => { }); it('respect max profile duration timeout', async () => { - jest.useFakeTimers(); + jest.useFakeTimers({ legacyFakeTimers: true }); const startProfilingSpy = jest.spyOn(profiler, 'startProfiling'); const stopProfilingSpy = jest.spyOn(profiler, 'stopProfiling'); const transport = Sentry.getCurrentHub().getClient()?.getTransport(); From e2658addcc460c033d58fb882da0e37cd5a52827 Mon Sep 17 00:00:00 2001 From: JonasBa Date: Fri, 13 Jan 2023 10:54:07 -0500 Subject: [PATCH 4/4] test(hub): use legacy timers --- src/hubextensions.hub.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hubextensions.hub.test.ts b/src/hubextensions.hub.test.ts index e83a62f4..2646fd83 100644 --- a/src/hubextensions.hub.test.ts +++ b/src/hubextensions.hub.test.ts @@ -47,6 +47,9 @@ describe('hubextensions', () => { }); it('respect max profile duration timeout', async () => { + // it seems that in node 19 globals (or least part of them) are a readonly object + // so when useFakeTimers is called it throws an error because it cannot override + // a readonly property of performance on global object. Use legacyFakeTimers for now jest.useFakeTimers({ legacyFakeTimers: true }); const startProfilingSpy = jest.spyOn(profiler, 'startProfiling'); const stopProfilingSpy = jest.spyOn(profiler, 'stopProfiling');