Skip to content

Commit cbb9475

Browse files
authored
feat(wasm): Unconditionally parse instruction addresses (#13655)
Currently we are only setting the `platform` and `instruction_addr` for a wasm frame if we find a matching debug image. This is not always the case and unconditionally parsing the instruction address is almost always desirable.
1 parent 0f122a1 commit cbb9475

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

packages/wasm/src/index.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@ const _wasmIntegration = (() => {
1313
patchWebAssembly();
1414
},
1515
processEvent(event: Event): Event {
16-
let haveWasm = false;
16+
let hasAtLeastOneWasmFrameWithImage = false;
1717

1818
if (event.exception && event.exception.values) {
1919
event.exception.values.forEach(exception => {
2020
if (exception.stacktrace && exception.stacktrace.frames) {
21-
haveWasm = haveWasm || patchFrames(exception.stacktrace.frames);
21+
hasAtLeastOneWasmFrameWithImage =
22+
hasAtLeastOneWasmFrameWithImage || patchFrames(exception.stacktrace.frames);
2223
}
2324
});
2425
}
2526

26-
if (haveWasm) {
27+
if (hasAtLeastOneWasmFrameWithImage) {
2728
event.debug_meta = event.debug_meta || {};
2829
event.debug_meta.images = [...(event.debug_meta.images || []), ...getImages()];
2930
}
@@ -37,10 +38,11 @@ export const wasmIntegration = defineIntegration(_wasmIntegration);
3738

3839
/**
3940
* Patches a list of stackframes with wasm data needed for server-side symbolication
40-
* if applicable. Returns true if any frames were patched.
41+
* if applicable. Returns true if the provided list of stack frames had at least one
42+
* matching registered image.
4143
*/
4244
function patchFrames(frames: Array<StackFrame>): boolean {
43-
let haveWasm = false;
45+
let hasAtLeastOneWasmFrameWithImage = false;
4446
frames.forEach(frame => {
4547
if (!frame.filename) {
4648
return;
@@ -50,14 +52,15 @@ function patchFrames(frames: Array<StackFrame>): boolean {
5052
| [string, string, string];
5153
if (match) {
5254
const index = getImage(match[1]);
55+
frame.instruction_addr = match[2];
56+
frame.filename = match[1];
57+
frame.platform = 'native';
58+
5359
if (index >= 0) {
54-
frame.instruction_addr = match[2];
5560
frame.addr_mode = `rel:${index}`;
56-
frame.filename = match[1];
57-
frame.platform = 'native';
58-
haveWasm = true;
61+
hasAtLeastOneWasmFrameWithImage = true;
5962
}
6063
}
6164
});
62-
return haveWasm;
65+
return hasAtLeastOneWasmFrameWithImage;
6366
}

0 commit comments

Comments
 (0)