diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33c9524..dbb5683 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -324,7 +324,7 @@ jobs: macos-15-intel, # macOS x64 windows-latest, ] - node: [18, 20, 22, 24] + node: [18, 20, 22, 24, 25] steps: - name: Check out current commit uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 diff --git a/module.cc b/module.cc index 9e9731a..6945d36 100644 --- a/module.cc +++ b/module.cc @@ -467,18 +467,13 @@ void CaptureStackTraces(const FunctionCallbackInfo &args) { capture_from_isolate, result.poll_state.c_str(), NewStringType::kNormal); if (!stateStr.IsEmpty()) { - v8::MaybeLocal maybeStateVal = - v8::JSON::Parse(current_context, stateStr.ToLocalChecked()); - v8::Local stateVal; - if (maybeStateVal.ToLocal(&stateVal)) { - threadObj - ->Set(current_context, - String::NewFromUtf8(capture_from_isolate, "pollState", - NewStringType::kInternalized) - .ToLocalChecked(), - stateVal) - .Check(); - } + threadObj + ->Set(current_context, + String::NewFromUtf8(capture_from_isolate, "pollState", + NewStringType::kInternalized) + .ToLocalChecked(), + stateStr.ToLocalChecked()) + .Check(); } } @@ -487,18 +482,13 @@ void CaptureStackTraces(const FunctionCallbackInfo &args) { capture_from_isolate, result.stack_trace.async_state.c_str(), NewStringType::kNormal); if (!stateStr.IsEmpty()) { - v8::MaybeLocal maybeStateVal = - v8::JSON::Parse(current_context, stateStr.ToLocalChecked()); - v8::Local stateVal; - if (maybeStateVal.ToLocal(&stateVal)) { - threadObj - ->Set(current_context, - String::NewFromUtf8(capture_from_isolate, "asyncState", - NewStringType::kInternalized) - .ToLocalChecked(), - stateVal) - .Check(); - } + threadObj + ->Set(current_context, + String::NewFromUtf8(capture_from_isolate, "asyncState", + NewStringType::kInternalized) + .ToLocalChecked(), + stateStr.ToLocalChecked()) + .Check(); } } diff --git a/package.json b/package.json index 74e4056..e45b5e3 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ }, "dependencies": { "detect-libc": "^2.0.4", - "node-abi": "^3.73.0" + "node-abi": "^3.89.0" }, "devDependencies": { "@sentry-internal/eslint-config-sdk": "^9.22.0", diff --git a/scripts/check-build.mjs b/scripts/check-build.mjs index 811f3cc..03eb347 100644 --- a/scripts/check-build.mjs +++ b/scripts/check-build.mjs @@ -9,7 +9,7 @@ function clean(err) { return err.toString().trim(); } -function recompileFromSource() { +async function recompileFromSource() { console.log('Compiling from source...'); let spawn = child_process.spawnSync('node-gyp', ['configure'], { stdio: ['inherit', 'inherit', 'pipe'], @@ -31,6 +31,8 @@ function recompileFromSource() { console.log(clean(spawn.stderr)); return; } + + await import('./copy-target.mjs'); } if (fs.existsSync(binaries.target)) { @@ -44,14 +46,10 @@ if (fs.existsSync(binaries.target)) { } else { console.log(e); } - try { - recompileFromSource(); - } catch (e) { - console.log('Failed to compile from source'); - throw e; - } + + await recompileFromSource(); } } else { console.log('No precompiled binary found'); - recompileFromSource(); + await recompileFromSource(); } diff --git a/src/index.ts b/src/index.ts index 810066e..2bfcf60 100644 --- a/src/index.ts +++ b/src/index.ts @@ -49,7 +49,7 @@ interface Native { registerThread(threadName: string): void; registerThread(storage: AsyncStorageArgs, threadName: string): void; threadPoll(enableLastSeen?: boolean, pollState?: object): void; - captureStackTrace(): Record>; + captureStackTrace(): Record>; getThreadsLastSeen(): Record; } @@ -230,7 +230,20 @@ export function threadPoll(enableLastSeen: boolean = true, pollState?: object): * Captures stack traces for all registered threads. */ export function captureStackTrace(): Record> { - return native.captureStackTrace(); + const result = native.captureStackTrace(); + + // Parse the asyncState and pollState from JSON strings back into objects + const transformedResult: Record> = {}; + for (const [key, value] of Object.entries(result)) { + const thread: Thread = { + frames: value.frames, + ...(value.asyncState && { asyncState: JSON.parse(value.asyncState) }), + ...(value.pollState && { pollState: JSON.parse(value.pollState) }), + }; + transformedResult[key] = thread; + } + + return transformedResult; } /** diff --git a/yarn.lock b/yarn.lock index 96a7d8a..4189920 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2291,10 +2291,10 @@ negotiator@^1.0.0: resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-1.0.0.tgz#b6c91bb47172d69f93cfd7c357bbb529019b5f6a" integrity sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg== -node-abi@^3.73.0: - version "3.75.0" - resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-3.75.0.tgz#2f929a91a90a0d02b325c43731314802357ed764" - integrity sha512-OhYaY5sDsIka7H7AtijtI9jwGYLyl29eQn/W623DiN/MIv5sUqc4g7BIDThX+gb7di9f6xK02nkp8sdfFWZLTg== +node-abi@^3.89.0: + version "3.89.0" + resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-3.89.0.tgz#eea98bf89d4534743bbbf2defa9f4f9bd3bdccfd" + integrity sha512-6u9UwL0HlAl21+agMN3YAMXcKByMqwGx+pq+P76vii5f7hTPtKDp08/H9py6DY+cfDw7kQNTGEj/rly3IgbNQA== dependencies: semver "^7.3.5"