@goliapkg/sentori-react-native 0.5.6 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-symbolicate.d.ts","sourceRoot":"","sources":["../../src/handlers/dev-symbolicate.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"dev-symbolicate.d.ts","sourceRoot":"","sources":["../../src/handlers/dev-symbolicate.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAqFpD;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,KAAK,EAAE,EACf,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAC1B,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAwBzB;AAED;+DAC+D;AAC/D,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,YAAY,EACjB,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAC1B,OAAO,CAAC,IAAI,CAAC,CAIf"}
|
|
@@ -8,14 +8,39 @@
|
|
|
8
8
|
// bad response) leaves the stack untouched. Never throws.
|
|
9
9
|
const TIMEOUT_MS = 2000;
|
|
10
10
|
/** Resolve `<devServer>/symbolicate`, or null if we're not running
|
|
11
|
-
* from a Metro dev server (release build, or not in RN).
|
|
11
|
+
* from a Metro dev server (release build, or not in RN).
|
|
12
|
+
*
|
|
13
|
+
* Order matters:
|
|
14
|
+
* 1. `react-native/Libraries/Core/Devtools/getDevServer` — the same
|
|
15
|
+
* helper LogBox + RN's own symbolicateStackTrace use. Works under
|
|
16
|
+
* both the legacy bridge and the new architecture (TurboModule),
|
|
17
|
+
* because internally it calls `NativeSourceCode.getConstants()`
|
|
18
|
+
* which is the correct path on new arch.
|
|
19
|
+
* 2. `NativeModules.SourceCode.getConstants().scriptURL` — direct
|
|
20
|
+
* TurboModule fallback if (1) ever moves.
|
|
21
|
+
* 3. `NativeModules.SourceCode.scriptURL` — legacy bridge (pre-new-
|
|
22
|
+
* arch RN). On new arch this property is `undefined` because
|
|
23
|
+
* constants aren't hoisted onto the module object — which is
|
|
24
|
+
* exactly the symptom Insight hit on RN 0.83 + new arch.
|
|
25
|
+
*/
|
|
12
26
|
function metroSymbolicateUrl() {
|
|
13
27
|
try {
|
|
14
|
-
//
|
|
15
|
-
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
29
|
+
const mod = require('react-native/Libraries/Core/Devtools/getDevServer');
|
|
30
|
+
const getDevServer = mod.default ?? mod;
|
|
31
|
+
const ds = getDevServer();
|
|
32
|
+
if (ds.bundleLoadedFromServer && typeof ds.url === 'string') {
|
|
33
|
+
return ds.url.replace(/\/$/, '') + '/symbolicate';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// Older RN / non-RN runtime / path moved → fall through to NativeModules.
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
16
40
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
17
41
|
const rn = require('react-native');
|
|
18
|
-
const
|
|
42
|
+
const sc = rn.NativeModules?.SourceCode;
|
|
43
|
+
const scriptURL = sc?.scriptURL ?? sc?.getConstants?.()?.scriptURL;
|
|
19
44
|
if (!scriptURL || !/^https?:\/\//.test(scriptURL))
|
|
20
45
|
return null;
|
|
21
46
|
const u = new URL(scriptURL);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-symbolicate.js","sourceRoot":"","sources":["../../src/handlers/dev-symbolicate.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,oEAAoE;AACpE,sEAAsE;AACtE,qEAAqE;AACrE,gEAAgE;AAChE,EAAE;AACF,qEAAqE;AACrE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CAAC,CAAC;IAC5D,IAAI,GAAG;QAAE,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC;IACzB,IAAI,GAAG,CAAC,KAAK;QAAE,MAAM,wBAAwB,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACjE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goliapkg/sentori-react-native",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "Sentori SDK for React Native
|
|
3
|
+
"version": "0.5.7",
|
|
4
|
+
"description": "Sentori SDK for React Native — JS-layer error capture, native crash handlers (iOS / Android), batched transport, fetch + react-navigation tracing.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://sentori.golia.jp",
|
|
7
7
|
"repository": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, mock, test } from 'bun:test';
|
|
2
2
|
|
|
3
3
|
import { symbolicateErrorViaMetro, symbolicateStackViaMetro } from '../handlers/dev-symbolicate';
|
|
4
4
|
import type { Frame, SentoriError } from '../types';
|
|
@@ -107,6 +107,39 @@ describe('symbolicateStackViaMetro', () => {
|
|
|
107
107
|
});
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
+
describe('metroSymbolicateUrl resolution (RN 0.83 new-arch regression)', () => {
|
|
111
|
+
// Without `opts.url`, the function must resolve a real Metro URL.
|
|
112
|
+
// RN 0.83 + new architecture leaves `NativeModules.SourceCode.scriptURL`
|
|
113
|
+
// undefined; the fix is to prefer RN's own `getDevServer()` helper,
|
|
114
|
+
// which internally calls `NativeSourceCode.getConstants().scriptURL`
|
|
115
|
+
// and works on both old and new arch.
|
|
116
|
+
test('prefers getDevServer() when available (works on new arch)', async () => {
|
|
117
|
+
mock.module('react-native/Libraries/Core/Devtools/getDevServer', () => ({
|
|
118
|
+
default: () => ({ bundleLoadedFromServer: true, url: 'http://192.168.1.100:8081/' }),
|
|
119
|
+
}));
|
|
120
|
+
const calls: string[] = [];
|
|
121
|
+
globalThis.fetch = (async (url: Request | string | URL) => {
|
|
122
|
+
calls.push(String(url));
|
|
123
|
+
return new Response(metroReply([{ col: 1, file: '/proj/src/a.ts', fn: 'a', line: 5 }]), {
|
|
124
|
+
headers: { 'content-type': 'application/json' },
|
|
125
|
+
status: 200,
|
|
126
|
+
});
|
|
127
|
+
}) as typeof fetch;
|
|
128
|
+
|
|
129
|
+
const out = await symbolicateStackViaMetro([minified(1)]);
|
|
130
|
+
expect(calls[0]).toBe('http://192.168.1.100:8081/symbolicate');
|
|
131
|
+
expect(out![0]?.file).toBe('/proj/src/a.ts');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test('returns null when getDevServer says bundle was not loaded from Metro', async () => {
|
|
135
|
+
mock.module('react-native/Libraries/Core/Devtools/getDevServer', () => ({
|
|
136
|
+
default: () => ({ bundleLoadedFromServer: false, url: 'http://localhost:8081/' }),
|
|
137
|
+
}));
|
|
138
|
+
// No fallback chain hit either (NativeModules require still throws in bun env)
|
|
139
|
+
expect(await symbolicateStackViaMetro([minified(1)])).toBeNull();
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
110
143
|
describe('symbolicateErrorViaMetro', () => {
|
|
111
144
|
test('replaces stack in place and recurses into the cause chain', async () => {
|
|
112
145
|
globalThis.fetch = (async () =>
|
|
@@ -21,16 +21,47 @@ type MetroFrame = {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
/** Resolve `<devServer>/symbolicate`, or null if we're not running
|
|
24
|
-
* from a Metro dev server (release build, or not in RN).
|
|
24
|
+
* from a Metro dev server (release build, or not in RN).
|
|
25
|
+
*
|
|
26
|
+
* Order matters:
|
|
27
|
+
* 1. `react-native/Libraries/Core/Devtools/getDevServer` — the same
|
|
28
|
+
* helper LogBox + RN's own symbolicateStackTrace use. Works under
|
|
29
|
+
* both the legacy bridge and the new architecture (TurboModule),
|
|
30
|
+
* because internally it calls `NativeSourceCode.getConstants()`
|
|
31
|
+
* which is the correct path on new arch.
|
|
32
|
+
* 2. `NativeModules.SourceCode.getConstants().scriptURL` — direct
|
|
33
|
+
* TurboModule fallback if (1) ever moves.
|
|
34
|
+
* 3. `NativeModules.SourceCode.scriptURL` — legacy bridge (pre-new-
|
|
35
|
+
* arch RN). On new arch this property is `undefined` because
|
|
36
|
+
* constants aren't hoisted onto the module object — which is
|
|
37
|
+
* exactly the symptom Insight hit on RN 0.83 + new arch.
|
|
38
|
+
*/
|
|
25
39
|
function metroSymbolicateUrl(): null | string {
|
|
26
40
|
try {
|
|
27
|
-
//
|
|
28
|
-
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
42
|
+
const mod = require('react-native/Libraries/Core/Devtools/getDevServer') as {
|
|
43
|
+
default?: () => { bundleLoadedFromServer: boolean; url: string };
|
|
44
|
+
};
|
|
45
|
+
const getDevServer = mod.default ?? (mod as unknown as () => { bundleLoadedFromServer: boolean; url: string });
|
|
46
|
+
const ds = getDevServer();
|
|
47
|
+
if (ds.bundleLoadedFromServer && typeof ds.url === 'string') {
|
|
48
|
+
return ds.url.replace(/\/$/, '') + '/symbolicate';
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
// Older RN / non-RN runtime / path moved → fall through to NativeModules.
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
29
54
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
30
55
|
const rn = require('react-native') as {
|
|
31
|
-
NativeModules?: {
|
|
56
|
+
NativeModules?: {
|
|
57
|
+
SourceCode?: {
|
|
58
|
+
getConstants?: () => { scriptURL?: string };
|
|
59
|
+
scriptURL?: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
32
62
|
};
|
|
33
|
-
const
|
|
63
|
+
const sc = rn.NativeModules?.SourceCode;
|
|
64
|
+
const scriptURL = sc?.scriptURL ?? sc?.getConstants?.()?.scriptURL;
|
|
34
65
|
if (!scriptURL || !/^https?:\/\//.test(scriptURL)) return null;
|
|
35
66
|
const u = new URL(scriptURL);
|
|
36
67
|
return `${u.protocol}//${u.host}/symbolicate`;
|