@logbrew/react-native 0.1.33 → 0.1.35
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.
- package/README.md +23 -1
- package/android/src/main/java/co/logbrew/reactnative/AndroidNativeDiagnostics.java +34 -1
- package/android/src/main/java/co/logbrew/reactnative/FatalStoreModuleImpl.java +8 -3
- package/fatal-replay.cjs +97 -110
- package/global-errors.cjs +94 -130
- package/global-errors.d.cts +23 -3
- package/global-errors.d.ts +23 -3
- package/index.cjs +44 -19
- package/index.native.js +4 -3
- package/instrumentation.cjs +80 -55
- package/ios/AppleDiagnostics/LBRNAppleNativeDiagnostics.swift +1 -1
- package/ios/GeneratedAppleDiagnostics/LogBrewCrash/NativeCrashCorrelation.swift +2 -0
- package/ios/GeneratedAppleDiagnostics/LogBrewCrash/NativeCrashReplay.swift +31 -7
- package/ios/GeneratedAppleDiagnostics/SOURCE-MANIFEST.json +2 -2
- package/metadata.cjs +1 -1
- package/native-bridge.cjs +112 -8
- package/native-bridge.d.cts +34 -0
- package/native-bridge.d.ts +34 -0
- package/native-bridge.js +2 -1
- package/package.json +2 -2
- package/promise-rejections.cjs +11 -1
- package/release-artifacts.cjs +1 -2
package/README.md
CHANGED
|
@@ -283,7 +283,16 @@ status. The Node ESM and CommonJS entries never import React Native;
|
|
|
283
283
|
non-React-Native callers may still inject the documented advanced `fatalStore`
|
|
284
284
|
adapter.
|
|
285
285
|
|
|
286
|
-
Automatic events
|
|
286
|
+
Automatic events keep structured stack frames with the file basename, line,
|
|
287
|
+
column, function name, and the bundle Debug ID that symbolication needs,
|
|
288
|
+
including Hermes bytecode positions. They also keep the error type, the client
|
|
289
|
+
breadcrumbs and context (such as release and session), and the last route that
|
|
290
|
+
the screen or navigation helpers recorded, as `metadata.lastRoute`. They
|
|
291
|
+
exclude the original error message, raw stack text, arbitrary metadata, full
|
|
292
|
+
URLs, hosts, query strings, local directories, payloads, and native error text.
|
|
293
|
+
The exception chain marks the removed message as `redacted`. Records replayed
|
|
294
|
+
from an injected `fatalStore` keep only the file basename, line, and column of
|
|
295
|
+
each frame. `onDiagnostic` receives only a fixed code. This error-handler integration does not claim mathematically exactly-once delivery, native crash capture, ANR or hang detection, or symbolication. The client-level persistent queue owns restart delivery.
|
|
287
296
|
|
|
288
297
|
### Apple native crash and app-hang diagnostics
|
|
289
298
|
|
|
@@ -330,6 +339,12 @@ Capture excludes messages, thread names, console output, local variables,
|
|
|
330
339
|
request data, authentication values, device identifiers, and raw tombstones. Java and
|
|
331
340
|
hang reports keep at most 32 frames; NDK reports keep one build ID and offset.
|
|
332
341
|
|
|
342
|
+
React Native ends a fatal JavaScript error on Android with a
|
|
343
|
+
`JavascriptException` crash. When the global error handler persisted that
|
|
344
|
+
fatal report in the same process less than 10 seconds earlier, Android
|
|
345
|
+
diagnostics skip the crash once, so one JavaScript fatal produces one issue.
|
|
346
|
+
Otherwise the crash is recorded as usual.
|
|
347
|
+
|
|
333
348
|
`uninstallLogBrewAndroidNativeDiagnostics()` reinstates prior
|
|
334
349
|
handlers, stops the watchdog, and leaves queued events available. After closing
|
|
335
350
|
the client, purge only for an explicit discard. Upload exact-release Android
|
|
@@ -425,6 +440,13 @@ clears both the JavaScript history and its native crash snapshot. Missing,
|
|
|
425
440
|
corrupt, and captured breadcrumb state remains explicit on replay; corrupt
|
|
426
441
|
optional context never discards the crash.
|
|
427
442
|
|
|
443
|
+
React Native ends a fatal JavaScript error on iOS with an `RCTFatalException`.
|
|
444
|
+
After the global error handler stores that fatal report, it adds a
|
|
445
|
+
`react-native.fatal` breadcrumb. When that breadcrumb is the last one in the
|
|
446
|
+
native crash report, replay discards the `RCTFatalException` report and counts
|
|
447
|
+
it as `discarded`, so one JavaScript fatal produces one issue. Otherwise the
|
|
448
|
+
native crash replays as usual.
|
|
449
|
+
|
|
428
450
|
Installation creates app-private, data-protected storage that iOS excludes from
|
|
429
451
|
device data archives. Pending reports are partitioned by project, so changing
|
|
430
452
|
the configured project does not replay an earlier project's records with the
|
|
@@ -85,6 +85,11 @@ final class AndroidNativeDiagnostics {
|
|
|
85
85
|
private static final int MAX_FRAMES = 32;
|
|
86
86
|
static final long WATCHDOG_POLL_MS = 500;
|
|
87
87
|
private static final AtomicLong SEQUENCE = new AtomicLong();
|
|
88
|
+
private static final String JAVASCRIPT_FATAL_RECORD = "{\"type\":\"issue\",\"id\":\"evt_rn_fatal_";
|
|
89
|
+
private static final String JAVASCRIPT_EXCEPTION = "com.facebook.react.common.JavascriptException";
|
|
90
|
+
private static final long JAVASCRIPT_FATAL_WINDOW_NANOS = 10_000_000_000L;
|
|
91
|
+
private static long javaScriptFatalPersistedAtNanos;
|
|
92
|
+
private static boolean javaScriptFatalUnclaimed;
|
|
88
93
|
|
|
89
94
|
final EventRecordStore eventStore;
|
|
90
95
|
final AndroidNativeSignalStore signalStore;
|
|
@@ -138,7 +143,9 @@ final class AndroidNativeDiagnostics {
|
|
|
138
143
|
|
|
139
144
|
void handleUncaught(Thread thread, Throwable error) {
|
|
140
145
|
try {
|
|
141
|
-
|
|
146
|
+
if (!claimPersistedJavaScriptFatal(error, System.nanoTime())) {
|
|
147
|
+
append(javaCrashEvent(error));
|
|
148
|
+
}
|
|
142
149
|
} finally {
|
|
143
150
|
previousHandler.uncaughtException(thread, error);
|
|
144
151
|
}
|
|
@@ -153,6 +160,32 @@ final class AndroidNativeDiagnostics {
|
|
|
153
160
|
append(hangEvent(mainFrames.get(), boundedDuration));
|
|
154
161
|
}
|
|
155
162
|
|
|
163
|
+
/** Notes a JavaScript fatal report that this process just persisted to the shared queue. */
|
|
164
|
+
static synchronized void notePersistedRecord(String serializedEvent, long nowNanos) {
|
|
165
|
+
if (serializedEvent != null
|
|
166
|
+
&& serializedEvent.startsWith(JAVASCRIPT_FATAL_RECORD)
|
|
167
|
+
&& !serializedEvent.contains("\"replayed\":true")) {
|
|
168
|
+
javaScriptFatalPersistedAtNanos = nowNanos;
|
|
169
|
+
javaScriptFatalUnclaimed = true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// React Native ends a JavaScript fatal by throwing JavascriptException right after
|
|
174
|
+
// the global handler runs. Skip that copy once, and only shortly after a persisted
|
|
175
|
+
// report, so a stale report can never hide a later crash.
|
|
176
|
+
static synchronized boolean claimPersistedJavaScriptFatal(Throwable error, long nowNanos) {
|
|
177
|
+
Throwable cause = error;
|
|
178
|
+
for (int depth = 0; cause != null && depth < 8; depth++, cause = cause.getCause()) {
|
|
179
|
+
if (JAVASCRIPT_EXCEPTION.equals(cause.getClass().getName())) {
|
|
180
|
+
boolean claimed = javaScriptFatalUnclaimed
|
|
181
|
+
&& nowNanos - javaScriptFatalPersistedAtNanos <= JAVASCRIPT_FATAL_WINDOW_NANOS;
|
|
182
|
+
javaScriptFatalUnclaimed = false;
|
|
183
|
+
return claimed;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
|
|
156
189
|
static boolean shouldReportHang(
|
|
157
190
|
long elapsedMs, long thresholdMs, boolean debugging, boolean processNotResponding) {
|
|
158
191
|
return !debugging && processNotResponding && elapsedMs >= thresholdMs;
|
|
@@ -72,9 +72,14 @@ final class FatalStoreModuleImpl {
|
|
|
72
72
|
try {
|
|
73
73
|
EventRecordStore eventStore = eventStore(queueKey);
|
|
74
74
|
Integer byteCount = integer(eventBytes);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
if (eventStore == null || byteCount == null) {
|
|
76
|
+
return status("storage_error");
|
|
77
|
+
}
|
|
78
|
+
EventRecordStore.Result result = eventStore.append(serializedEvent, byteCount);
|
|
79
|
+
if ("appended".equals(result.status)) {
|
|
80
|
+
AndroidNativeDiagnostics.notePersistedRecord(serializedEvent, System.nanoTime());
|
|
81
|
+
}
|
|
82
|
+
return eventResultMap(result);
|
|
78
83
|
} catch (RuntimeException error) {
|
|
79
84
|
return status("storage_error");
|
|
80
85
|
}
|
package/fatal-replay.cjs
CHANGED
|
@@ -3,20 +3,21 @@
|
|
|
3
3
|
const FATAL_RECORD_SCHEMA_VERSION = 1;
|
|
4
4
|
const MAX_ADMITTED_FATAL_IDS = 256;
|
|
5
5
|
const MAX_FATAL_FILENAME_BYTES = 512;
|
|
6
|
-
const MAX_FATAL_STACK_BYTES = 16 * 1024;
|
|
7
6
|
const MAX_FATAL_STACK_FRAMES = 24;
|
|
7
|
+
const MAX_FATAL_ID_LENGTH = 128;
|
|
8
|
+
const MAX_FATAL_RECORD_BYTES = 16 * 1024;
|
|
8
9
|
const DURABLE_QUEUE = Symbol.for("co.logbrew.react-native.durable-event-queue");
|
|
9
10
|
|
|
10
11
|
const admittedFatalIdsByClient = new WeakMap();
|
|
11
|
-
let nextFatalSequence = 0;
|
|
12
12
|
|
|
13
13
|
function createFatalController({
|
|
14
14
|
client,
|
|
15
|
+
createEvent,
|
|
15
16
|
eventMessage,
|
|
16
17
|
fatalStore,
|
|
18
|
+
isErrorName,
|
|
17
19
|
issue,
|
|
18
|
-
onDiagnostic
|
|
19
|
-
sanitizers
|
|
20
|
+
onDiagnostic
|
|
20
21
|
}) {
|
|
21
22
|
const methods = fatalStoreMethods(fatalStore);
|
|
22
23
|
const directAdmission = !methods && safeReadProperty(client, DURABLE_QUEUE) === true;
|
|
@@ -46,42 +47,47 @@ function createFatalController({
|
|
|
46
47
|
client,
|
|
47
48
|
eventMessage,
|
|
48
49
|
fatalStore,
|
|
50
|
+
isErrorName,
|
|
49
51
|
issue,
|
|
50
52
|
methods,
|
|
51
53
|
onDiagnostic,
|
|
52
|
-
sanitizers,
|
|
53
54
|
state
|
|
54
55
|
});
|
|
55
56
|
},
|
|
56
57
|
store(error) {
|
|
57
58
|
if (!methods) {
|
|
58
59
|
return directAdmission
|
|
59
|
-
? admitFatalError({ client,
|
|
60
|
+
? admitFatalError({ client, createEvent, error, issue, onDiagnostic, state })
|
|
60
61
|
: false;
|
|
61
62
|
}
|
|
62
63
|
return storeFatalError({
|
|
64
|
+
createEvent,
|
|
63
65
|
error,
|
|
64
66
|
fatalStore,
|
|
65
67
|
methods,
|
|
66
68
|
onDiagnostic,
|
|
67
|
-
sanitizers,
|
|
68
69
|
state
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
function admitFatalError({ client,
|
|
75
|
-
|
|
76
|
-
const before = admissionSnapshot(client);
|
|
75
|
+
function admitFatalError({ client, createEvent, error, issue, onDiagnostic, state }) {
|
|
76
|
+
let admission;
|
|
77
77
|
try {
|
|
78
|
-
|
|
78
|
+
const event = createEvent(error);
|
|
79
|
+
admission = captureIssueWithAdmission(client, issue, event.id, event.timestamp, event.attributes);
|
|
79
80
|
} catch {
|
|
80
81
|
state.lastOutcome = "storage_error";
|
|
81
82
|
emitDiagnostic(onDiagnostic, "fatal_store_failed");
|
|
82
83
|
return false;
|
|
83
84
|
}
|
|
84
|
-
if (
|
|
85
|
+
if (admission === "unavailable") {
|
|
86
|
+
state.lastOutcome = "admission_unavailable";
|
|
87
|
+
emitDiagnostic(onDiagnostic, "fatal_admission_unavailable");
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
if (admission !== "admitted") {
|
|
85
91
|
state.lastOutcome = "storage_error";
|
|
86
92
|
emitDiagnostic(onDiagnostic, "fatal_store_failed");
|
|
87
93
|
return false;
|
|
@@ -130,11 +136,11 @@ function discardPendingFatal(fatalStore, methods, state, onDiagnostic) {
|
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
function storeFatalError({
|
|
139
|
+
createEvent,
|
|
133
140
|
error,
|
|
134
141
|
fatalStore,
|
|
135
142
|
methods,
|
|
136
143
|
onDiagnostic,
|
|
137
|
-
sanitizers,
|
|
138
144
|
state
|
|
139
145
|
}) {
|
|
140
146
|
if (!methods) {
|
|
@@ -142,7 +148,7 @@ function storeFatalError({
|
|
|
142
148
|
}
|
|
143
149
|
let result;
|
|
144
150
|
try {
|
|
145
|
-
result = methods.write.call(fatalStore, createFatalRecord(error
|
|
151
|
+
result = methods.write.call(fatalStore, createFatalRecord(createEvent(error)));
|
|
146
152
|
} catch {
|
|
147
153
|
result = undefined;
|
|
148
154
|
}
|
|
@@ -172,10 +178,10 @@ function replayPendingFatal({
|
|
|
172
178
|
client,
|
|
173
179
|
eventMessage,
|
|
174
180
|
fatalStore,
|
|
181
|
+
isErrorName,
|
|
175
182
|
issue,
|
|
176
183
|
methods,
|
|
177
184
|
onDiagnostic,
|
|
178
|
-
sanitizers,
|
|
179
185
|
state
|
|
180
186
|
}) {
|
|
181
187
|
if (!methods) {
|
|
@@ -203,7 +209,7 @@ function replayPendingFatal({
|
|
|
203
209
|
return;
|
|
204
210
|
}
|
|
205
211
|
const record = status === "pending"
|
|
206
|
-
? validatedFatalRecord(safeReadProperty(result, "record"),
|
|
212
|
+
? validatedFatalRecord(safeReadProperty(result, "record"), isErrorName)
|
|
207
213
|
: undefined;
|
|
208
214
|
if (!record) {
|
|
209
215
|
state.lastOutcome = "replay_failed";
|
|
@@ -218,16 +224,22 @@ function replayPendingFatal({
|
|
|
218
224
|
return;
|
|
219
225
|
}
|
|
220
226
|
|
|
221
|
-
|
|
227
|
+
let admission;
|
|
222
228
|
try {
|
|
223
|
-
|
|
229
|
+
admission = captureIssueWithAdmission(
|
|
230
|
+
client, issue, record.id, record.timestamp, fatalEventAttributes(record, eventMessage)
|
|
231
|
+
);
|
|
224
232
|
} catch {
|
|
225
233
|
state.lastOutcome = "replay_failed";
|
|
226
234
|
emitDiagnostic(onDiagnostic, "fatal_replay_failed");
|
|
227
235
|
return;
|
|
228
236
|
}
|
|
229
|
-
|
|
230
|
-
|
|
237
|
+
if (admission === "unavailable") {
|
|
238
|
+
state.lastOutcome = "admission_unavailable";
|
|
239
|
+
emitDiagnostic(onDiagnostic, "fatal_replay_admission_unavailable");
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (admission !== "admitted") {
|
|
231
243
|
state.lastOutcome = "replay_not_admitted";
|
|
232
244
|
emitDiagnostic(onDiagnostic, "fatal_replay_not_admitted");
|
|
233
245
|
return;
|
|
@@ -255,28 +267,16 @@ function acknowledgeFatalRecord(fatalStore, methods, recordId, state, onDiagnost
|
|
|
255
267
|
emitDiagnostic(onDiagnostic, "fatal_acknowledge_failed");
|
|
256
268
|
}
|
|
257
269
|
|
|
258
|
-
function
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
return
|
|
263
|
-
}
|
|
264
|
-
try {
|
|
265
|
-
const pending = pendingEvents.call(client);
|
|
266
|
-
const dropped = droppedEvents.call(client);
|
|
267
|
-
return isBoundedCounter(pending) && isBoundedCounter(dropped)
|
|
268
|
-
? { dropped, pending }
|
|
269
|
-
: undefined;
|
|
270
|
-
} catch {
|
|
271
|
-
return undefined;
|
|
270
|
+
function captureIssueWithAdmission(client, issue, id, timestamp, attributes) {
|
|
271
|
+
const capture = safeFunction(client, "issueWithAdmission");
|
|
272
|
+
if (!capture) {
|
|
273
|
+
issue.call(client, id, timestamp, attributes);
|
|
274
|
+
return "unavailable";
|
|
272
275
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
&& after !== undefined
|
|
278
|
-
&& after.pending === before.pending + 1
|
|
279
|
-
&& after.dropped === before.dropped;
|
|
276
|
+
const status = resultStatus(capture.call(client, id, timestamp, attributes));
|
|
277
|
+
return status === "admitted" || status === "filtered" || status === "dropped"
|
|
278
|
+
? status
|
|
279
|
+
: "unavailable";
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
function wasAdmittedInRuntime(client, recordId) {
|
|
@@ -301,39 +301,23 @@ function rememberAdmittedFatalId(client, recordId) {
|
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
-
function createFatalRecord(
|
|
305
|
-
|
|
304
|
+
function createFatalRecord(event) {
|
|
305
|
+
const record = {
|
|
306
306
|
corruptRecords: 0,
|
|
307
307
|
droppedRecords: 0,
|
|
308
|
-
errorName:
|
|
309
|
-
id:
|
|
308
|
+
errorName: event.attributes.exception.type,
|
|
309
|
+
id: event.id,
|
|
310
310
|
schemaVersion: FATAL_RECORD_SCHEMA_VERSION,
|
|
311
|
-
stackFrames:
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
? stack.slice(0, MAX_FATAL_STACK_BYTES)
|
|
320
|
-
: "";
|
|
321
|
-
const frames = [];
|
|
322
|
-
for (const line of candidate.split(/\r?\n/u)) {
|
|
323
|
-
const frame = stackFrame(line);
|
|
324
|
-
const filename = frame ? normalizedStoredFatalFilename(frame.filename) : undefined;
|
|
325
|
-
if (filename && validFatalFilename(filename)) {
|
|
326
|
-
frames.push(Object.freeze({
|
|
327
|
-
column: frame.column,
|
|
328
|
-
filename,
|
|
329
|
-
line: frame.line
|
|
330
|
-
}));
|
|
331
|
-
if (frames.length === MAX_FATAL_STACK_FRAMES) {
|
|
332
|
-
break;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
311
|
+
stackFrames: (event.attributes.stackFrames ?? []).flatMap(({ column, filename, line }) => {
|
|
312
|
+
const stored = normalizedStoredFatalFilename(filename);
|
|
313
|
+
return validFatalFilename(stored) ? [{ column, filename: stored, line }] : [];
|
|
314
|
+
}).slice(0, MAX_FATAL_STACK_FRAMES),
|
|
315
|
+
timestamp: event.timestamp
|
|
316
|
+
};
|
|
317
|
+
while (record.stackFrames.length > 0 && utf8ByteLength(JSON.stringify(record)) > MAX_FATAL_RECORD_BYTES) {
|
|
318
|
+
record.stackFrames.pop();
|
|
335
319
|
}
|
|
336
|
-
return
|
|
320
|
+
return record;
|
|
337
321
|
}
|
|
338
322
|
|
|
339
323
|
function fatalEventAttributes(record, eventMessage) {
|
|
@@ -364,7 +348,7 @@ function fatalEventAttributes(record, eventMessage) {
|
|
|
364
348
|
});
|
|
365
349
|
}
|
|
366
350
|
|
|
367
|
-
function validatedFatalRecord(value,
|
|
351
|
+
function validatedFatalRecord(value, isErrorName) {
|
|
368
352
|
try {
|
|
369
353
|
if (!isPlainObject(value)
|
|
370
354
|
|| !hasExactKeys(value, [
|
|
@@ -375,31 +359,41 @@ function validatedFatalRecord(value, sanitizers) {
|
|
|
375
359
|
"schemaVersion",
|
|
376
360
|
"stackFrames",
|
|
377
361
|
"timestamp"
|
|
378
|
-
])
|
|
379
|
-
|| value.schemaVersion !== FATAL_RECORD_SCHEMA_VERSION
|
|
380
|
-
|| typeof value.id !== "string"
|
|
381
|
-
|| !/^evt_rn_fatal_[a-z0-9]+(?:_[a-z0-9]+)*$/u.test(value.id)
|
|
382
|
-
|| !sanitizers.isErrorName(value.errorName)
|
|
383
|
-
|| !isBoundedCounter(value.corruptRecords)
|
|
384
|
-
|| !isBoundedCounter(value.droppedRecords)
|
|
385
|
-
|| !validFatalTimestamp(value.timestamp)
|
|
386
|
-
|| !Array.isArray(value.stackFrames)
|
|
387
|
-
|| value.stackFrames.length > MAX_FATAL_STACK_FRAMES) {
|
|
362
|
+
])) {
|
|
388
363
|
return undefined;
|
|
389
364
|
}
|
|
390
|
-
const
|
|
391
|
-
|
|
365
|
+
const { corruptRecords, droppedRecords, errorName, id, schemaVersion, stackFrames, timestamp } = value;
|
|
366
|
+
const frameCount = Array.isArray(stackFrames) ? stackFrames.length : undefined;
|
|
367
|
+
if (schemaVersion !== FATAL_RECORD_SCHEMA_VERSION
|
|
368
|
+
|| typeof id !== "string"
|
|
369
|
+
|| id.length > MAX_FATAL_ID_LENGTH
|
|
370
|
+
|| !/^evt_rn_fatal_[a-z0-9]+(?:_[a-z0-9]+)*$/u.test(id)
|
|
371
|
+
|| !isErrorName(errorName)
|
|
372
|
+
|| !isBoundedCounter(corruptRecords)
|
|
373
|
+
|| !isBoundedCounter(droppedRecords)
|
|
374
|
+
|| !validFatalTimestamp(timestamp)
|
|
375
|
+
|| !isBoundedCounter(frameCount)
|
|
376
|
+
|| frameCount > MAX_FATAL_STACK_FRAMES) {
|
|
392
377
|
return undefined;
|
|
393
378
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
379
|
+
const frames = [];
|
|
380
|
+
for (let index = 0; index < frameCount; index += 1) {
|
|
381
|
+
const frame = validatedFatalFrame(stackFrames[index]);
|
|
382
|
+
if (!frame) {
|
|
383
|
+
return undefined;
|
|
384
|
+
}
|
|
385
|
+
frames.push(frame);
|
|
386
|
+
}
|
|
387
|
+
const record = {
|
|
388
|
+
corruptRecords,
|
|
389
|
+
droppedRecords,
|
|
390
|
+
errorName,
|
|
391
|
+
id,
|
|
399
392
|
schemaVersion: FATAL_RECORD_SCHEMA_VERSION,
|
|
400
393
|
stackFrames: frames,
|
|
401
|
-
timestamp
|
|
394
|
+
timestamp
|
|
402
395
|
};
|
|
396
|
+
return utf8ByteLength(JSON.stringify(record)) <= MAX_FATAL_RECORD_BYTES ? record : undefined;
|
|
403
397
|
} catch {
|
|
404
398
|
return undefined;
|
|
405
399
|
}
|
|
@@ -408,16 +402,19 @@ function validatedFatalRecord(value, sanitizers) {
|
|
|
408
402
|
function validatedFatalFrame(value) {
|
|
409
403
|
try {
|
|
410
404
|
if (!isPlainObject(value)
|
|
411
|
-
|| !hasExactKeys(value, ["column", "filename", "line"])
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
405
|
+
|| !hasExactKeys(value, ["column", "filename", "line"])) {
|
|
406
|
+
return undefined;
|
|
407
|
+
}
|
|
408
|
+
const { column, filename, line } = value;
|
|
409
|
+
if (!validFatalFilename(filename)
|
|
410
|
+
|| positiveInteger(line) === undefined
|
|
411
|
+
|| positiveInteger(column) === undefined) {
|
|
415
412
|
return undefined;
|
|
416
413
|
}
|
|
417
414
|
return {
|
|
418
|
-
column
|
|
419
|
-
filename
|
|
420
|
-
line
|
|
415
|
+
column,
|
|
416
|
+
filename,
|
|
417
|
+
line
|
|
421
418
|
};
|
|
422
419
|
} catch {
|
|
423
420
|
return undefined;
|
|
@@ -456,9 +453,8 @@ function validFatalTimestamp(value) {
|
|
|
456
453
|
|
|
457
454
|
function resultStatus(result) {
|
|
458
455
|
try {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
: undefined;
|
|
456
|
+
const status = isPlainObject(result) ? result.status : undefined;
|
|
457
|
+
return typeof status === "string" ? status : undefined;
|
|
462
458
|
} catch {
|
|
463
459
|
return undefined;
|
|
464
460
|
}
|
|
@@ -519,16 +515,7 @@ function hasControlCharacter(value) {
|
|
|
519
515
|
}
|
|
520
516
|
|
|
521
517
|
function positiveInteger(value) {
|
|
522
|
-
|
|
523
|
-
return undefined;
|
|
524
|
-
}
|
|
525
|
-
const number = Number(value);
|
|
526
|
-
return Number.isSafeInteger(number) && number <= 2147483647 ? number : undefined;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
function nextFatalEventId() {
|
|
530
|
-
nextFatalSequence = incrementBounded(nextFatalSequence);
|
|
531
|
-
return `evt_rn_fatal_${Date.now().toString(36)}_${nextFatalSequence.toString(36)}`;
|
|
518
|
+
return Number.isSafeInteger(value) && value > 0 && value <= 2147483647 ? value : undefined;
|
|
532
519
|
}
|
|
533
520
|
|
|
534
521
|
function incrementBounded(value) {
|
|
@@ -571,4 +558,4 @@ function isObjectLike(value) {
|
|
|
571
558
|
return value !== null && (typeof value === "object" || typeof value === "function");
|
|
572
559
|
}
|
|
573
560
|
|
|
574
|
-
module.exports = { createFatalController };
|
|
561
|
+
module.exports = { captureIssueWithAdmission, createFatalController };
|