Skip to content

Commit ad35117

Browse files
authored
feat: Support V8 v14 (#32)
1 parent 9de9147 commit ad35117

File tree

6 files changed

+41
-40
lines changed

6 files changed

+41
-40
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ jobs:
324324
macos-15-intel, # macOS x64
325325
windows-latest,
326326
]
327-
node: [18, 20, 22, 24]
327+
node: [18, 20, 22, 24, 25]
328328
steps:
329329
- name: Check out current commit
330330
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

module.cc

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -467,18 +467,13 @@ void CaptureStackTraces(const FunctionCallbackInfo<Value> &args) {
467467
capture_from_isolate, result.poll_state.c_str(),
468468
NewStringType::kNormal);
469469
if (!stateStr.IsEmpty()) {
470-
v8::MaybeLocal<v8::Value> maybeStateVal =
471-
v8::JSON::Parse(current_context, stateStr.ToLocalChecked());
472-
v8::Local<v8::Value> stateVal;
473-
if (maybeStateVal.ToLocal(&stateVal)) {
474-
threadObj
475-
->Set(current_context,
476-
String::NewFromUtf8(capture_from_isolate, "pollState",
477-
NewStringType::kInternalized)
478-
.ToLocalChecked(),
479-
stateVal)
480-
.Check();
481-
}
470+
threadObj
471+
->Set(current_context,
472+
String::NewFromUtf8(capture_from_isolate, "pollState",
473+
NewStringType::kInternalized)
474+
.ToLocalChecked(),
475+
stateStr.ToLocalChecked())
476+
.Check();
482477
}
483478
}
484479

@@ -487,18 +482,13 @@ void CaptureStackTraces(const FunctionCallbackInfo<Value> &args) {
487482
capture_from_isolate, result.stack_trace.async_state.c_str(),
488483
NewStringType::kNormal);
489484
if (!stateStr.IsEmpty()) {
490-
v8::MaybeLocal<v8::Value> maybeStateVal =
491-
v8::JSON::Parse(current_context, stateStr.ToLocalChecked());
492-
v8::Local<v8::Value> stateVal;
493-
if (maybeStateVal.ToLocal(&stateVal)) {
494-
threadObj
495-
->Set(current_context,
496-
String::NewFromUtf8(capture_from_isolate, "asyncState",
497-
NewStringType::kInternalized)
498-
.ToLocalChecked(),
499-
stateVal)
500-
.Check();
501-
}
485+
threadObj
486+
->Set(current_context,
487+
String::NewFromUtf8(capture_from_isolate, "asyncState",
488+
NewStringType::kInternalized)
489+
.ToLocalChecked(),
490+
stateStr.ToLocalChecked())
491+
.Check();
502492
}
503493
}
504494

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"dependencies": {
4242
"detect-libc": "^2.0.4",
43-
"node-abi": "^3.73.0"
43+
"node-abi": "^3.89.0"
4444
},
4545
"devDependencies": {
4646
"@sentry-internal/eslint-config-sdk": "^9.22.0",

scripts/check-build.mjs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function clean(err) {
99
return err.toString().trim();
1010
}
1111

12-
function recompileFromSource() {
12+
async function recompileFromSource() {
1313
console.log('Compiling from source...');
1414
let spawn = child_process.spawnSync('node-gyp', ['configure'], {
1515
stdio: ['inherit', 'inherit', 'pipe'],
@@ -31,6 +31,8 @@ function recompileFromSource() {
3131
console.log(clean(spawn.stderr));
3232
return;
3333
}
34+
35+
await import('./copy-target.mjs');
3436
}
3537

3638
if (fs.existsSync(binaries.target)) {
@@ -44,14 +46,10 @@ if (fs.existsSync(binaries.target)) {
4446
} else {
4547
console.log(e);
4648
}
47-
try {
48-
recompileFromSource();
49-
} catch (e) {
50-
console.log('Failed to compile from source');
51-
throw e;
52-
}
49+
50+
await recompileFromSource();
5351
}
5452
} else {
5553
console.log('No precompiled binary found');
56-
recompileFromSource();
54+
await recompileFromSource();
5755
}

src/index.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ interface Native {
4949
registerThread(threadName: string): void;
5050
registerThread(storage: AsyncStorageArgs, threadName: string): void;
5151
threadPoll(enableLastSeen?: boolean, pollState?: object): void;
52-
captureStackTrace<A = unknown, P = unknown>(): Record<string, Thread<A, P>>;
52+
captureStackTrace(): Record<string, Thread<string, string>>;
5353
getThreadsLastSeen(): Record<string, number>;
5454
}
5555

@@ -230,7 +230,20 @@ export function threadPoll(enableLastSeen: boolean = true, pollState?: object):
230230
* Captures stack traces for all registered threads.
231231
*/
232232
export function captureStackTrace<A = unknown, P = unknown>(): Record<string, Thread<A, P>> {
233-
return native.captureStackTrace<A, P>();
233+
const result = native.captureStackTrace();
234+
235+
// Parse the asyncState and pollState from JSON strings back into objects
236+
const transformedResult: Record<string, Thread<A, P>> = {};
237+
for (const [key, value] of Object.entries(result)) {
238+
const thread: Thread<A, P> = {
239+
frames: value.frames,
240+
...(value.asyncState && { asyncState: JSON.parse(value.asyncState) }),
241+
...(value.pollState && { pollState: JSON.parse(value.pollState) }),
242+
};
243+
transformedResult[key] = thread;
244+
}
245+
246+
return transformedResult;
234247
}
235248

236249
/**

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,10 +2291,10 @@ negotiator@^1.0.0:
22912291
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-1.0.0.tgz#b6c91bb47172d69f93cfd7c357bbb529019b5f6a"
22922292
integrity sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==
22932293

2294-
node-abi@^3.73.0:
2295-
version "3.75.0"
2296-
resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-3.75.0.tgz#2f929a91a90a0d02b325c43731314802357ed764"
2297-
integrity sha512-OhYaY5sDsIka7H7AtijtI9jwGYLyl29eQn/W623DiN/MIv5sUqc4g7BIDThX+gb7di9f6xK02nkp8sdfFWZLTg==
2294+
node-abi@^3.89.0:
2295+
version "3.89.0"
2296+
resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-3.89.0.tgz#eea98bf89d4534743bbbf2defa9f4f9bd3bdccfd"
2297+
integrity sha512-6u9UwL0HlAl21+agMN3YAMXcKByMqwGx+pq+P76vii5f7hTPtKDp08/H9py6DY+cfDw7kQNTGEj/rly3IgbNQA==
22982298
dependencies:
22992299
semver "^7.3.5"
23002300

0 commit comments

Comments
 (0)