@logbrew/react-native 0.1.34 → 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.
@@ -52,67 +52,70 @@ function createLogBrewReactNativeInstrumentation(client, {
52
52
  const activeTrace = resolveInstrumentationTrace({ randomValues, trace, traceFlags });
53
53
  const removers = [];
54
54
  const resolvedNavigation = navigationContainer ?? navigation;
55
+ let nativeScopeApplied = false;
56
+ let resourceFetch;
57
+ let globalFetch;
58
+ let globalXMLHttpRequest;
55
59
 
56
- if (appState?.addEventListener) {
57
- removers.push(createAppStateLifecycleSpanListener(client, appState, {
58
- captureInitialState: captureInitialLifecycleState,
59
- metadata,
60
- now,
61
- nowMs,
62
- onError,
63
- platform,
64
- screen,
65
- sessionId,
66
- trace: activeTrace
67
- }));
68
- }
60
+ try {
61
+ if (appState?.addEventListener) {
62
+ removers.push(createAppStateLifecycleSpanListener(client, appState, {
63
+ captureInitialState: captureInitialLifecycleState,
64
+ metadata,
65
+ now,
66
+ nowMs,
67
+ onError,
68
+ platform,
69
+ screen,
70
+ sessionId,
71
+ trace: activeTrace
72
+ }));
73
+ }
74
+
75
+ if (resolvedNavigation) {
76
+ removers.push(createReactNavigationSpanListener(client, resolvedNavigation, {
77
+ appState,
78
+ captureInitialRoute: captureInitialNavigationRoute,
79
+ includeRouteKey,
80
+ metadata,
81
+ now,
82
+ nowMs,
83
+ onError,
84
+ platform,
85
+ trace: activeTrace
86
+ }));
87
+ }
69
88
 
70
- if (resolvedNavigation) {
71
- removers.push(createReactNavigationSpanListener(client, resolvedNavigation, {
89
+ if (nativeBridge) {
90
+ syncLogBrewNativeBridgeScope(nativeBridge, {
91
+ logger,
92
+ metadata,
93
+ screen,
94
+ sessionId,
95
+ source: "react-native.instrumentation",
96
+ trace: activeTrace
97
+ });
98
+ nativeScopeApplied = true;
99
+ }
100
+
101
+ resourceFetch = createReactNativeResourceFetch(client, {
72
102
  appState,
73
- captureInitialRoute: captureInitialNavigationRoute,
74
- includeRouteKey,
103
+ fetchImpl,
104
+ measureResponseBodySize: measureFetchResponseBodySize,
75
105
  metadata,
106
+ metadataFactory,
76
107
  now,
77
108
  nowMs,
78
- onError,
79
109
  platform,
80
- trace: activeTrace
81
- }));
82
- }
83
-
84
- if (nativeBridge) {
85
- syncLogBrewNativeBridgeScope(nativeBridge, {
86
- logger,
87
- metadata,
110
+ randomValues,
111
+ routeTemplate,
112
+ routeTemplateFactory,
88
113
  screen,
89
114
  sessionId,
90
- source: "react-native.instrumentation",
91
- trace: activeTrace
115
+ trace: activeTrace,
116
+ traceFlags,
117
+ tracePropagationTargets
92
118
  });
93
- }
94
-
95
- const resourceFetch = createReactNativeResourceFetch(client, {
96
- appState,
97
- fetchImpl,
98
- measureResponseBodySize: measureFetchResponseBodySize,
99
- metadata,
100
- metadataFactory,
101
- now,
102
- nowMs,
103
- platform,
104
- randomValues,
105
- routeTemplate,
106
- routeTemplateFactory,
107
- screen,
108
- sessionId,
109
- trace: activeTrace,
110
- traceFlags,
111
- tracePropagationTargets
112
- });
113
- let globalFetch;
114
- let globalXMLHttpRequest;
115
- try {
116
119
  globalFetch = instrumentGlobalFetch ? installGlobalFetchInstrumentation(client, {
117
120
  appState,
118
121
  globalObject,
@@ -154,7 +157,14 @@ function createLogBrewReactNativeInstrumentation(client, {
154
157
  removers.push(globalXMLHttpRequest.remove);
155
158
  }
156
159
  } catch (error) {
157
- removeConfiguredInstrumentation({ nativeBridge, removers });
160
+ try {
161
+ removeConfiguredInstrumentation({
162
+ nativeBridge: nativeScopeApplied ? nativeBridge : undefined,
163
+ removers
164
+ });
165
+ } catch {
166
+ // Preserve the setup error after attempting every removal.
167
+ }
158
168
  throw error;
159
169
  }
160
170
 
@@ -163,8 +173,8 @@ function createLogBrewReactNativeInstrumentation(client, {
163
173
  if (removed) {
164
174
  return;
165
175
  }
166
- removed = true;
167
176
  removeConfiguredInstrumentation({ nativeBridge, removers });
177
+ removed = true;
168
178
  };
169
179
 
170
180
  const handle = {
@@ -230,11 +240,26 @@ function requireClient(client) {
230
240
  }
231
241
 
232
242
  function removeConfiguredInstrumentation({ nativeBridge, removers }) {
243
+ const failures = [];
244
+ const failedRemovers = [];
233
245
  if (nativeBridge) {
234
- clearLogBrewNativeBridgeScope(nativeBridge);
246
+ try {
247
+ clearLogBrewNativeBridgeScope(nativeBridge);
248
+ } catch (error) {
249
+ failures.push(error);
250
+ }
235
251
  }
236
252
  for (const removeListener of removers.splice(0).reverse()) {
237
- removeListener();
253
+ try {
254
+ removeListener();
255
+ } catch (error) {
256
+ failedRemovers.unshift(removeListener);
257
+ failures.push(error);
258
+ }
259
+ }
260
+ removers.push(...failedRemovers);
261
+ if (failures.length > 0) {
262
+ throw failures[0];
238
263
  }
239
264
  }
240
265
 
@@ -3,7 +3,7 @@ import Foundation
3
3
  @objc(LBRNAppleNativeDiagnostics)
4
4
  public final class LBRNAppleNativeDiagnostics: NSObject, @unchecked Sendable {
5
5
  private static let shared = LBRNAppleNativeDiagnostics()
6
- private static let sdkVersion = "0.1.34"
6
+ private static let sdkVersion = "0.1.35"
7
7
 
8
8
  private let lock = NSLock()
9
9
  private let replayQueue = DispatchQueue(label: "co.logbrew.react-native.apple-diagnostics-replay")
@@ -103,6 +103,8 @@ struct NativeCrashBreadcrumbSnapshot: Codable, Equatable {
103
103
 
104
104
  enum NativeCrashBreadcrumbs {
105
105
  static let reportKey = "logbrew_native_breadcrumbs"
106
+ /// The React Native package records this category after it persists a JavaScript fatal report.
107
+ static let javaScriptFatalCategory = "react-native.fatal"
106
108
  static let maximumBytes = 64 * 1024
107
109
 
108
110
  static func encoded(_ values: [IssueBreadcrumb]?, truncated: Bool) throws -> String? {
@@ -180,19 +180,43 @@ private extension NativeCrashCapture {
180
180
  guard let rawReport = store.report(for: reportID) else {
181
181
  throw NativeCrashError(.reportChanged)
182
182
  }
183
+ if repeatsPersistedJavaScriptFatal(rawReport) {
184
+ return try discardEngineReport(reportID, expectedReportIDs: expectedReportIDs, store: store)
185
+ }
183
186
  do {
184
187
  let record = try sanitizer.makeRecord(reportID: reportID, rawReport: rawReport)
185
188
  try verifyReportIDs(expectedReportIDs, in: store)
186
189
  return .record(record)
187
190
  } catch let error as NativeCrashError where error.code == .reportCorrupt {
188
- try verifyReportIDs(expectedReportIDs, in: store)
189
- store.deleteReport(with: reportID)
190
- guard !store.reportIDs.contains(reportID) else {
191
- throw NativeCrashError(.reportDeletionFailed)
192
- }
193
- recordDiscardedLocked()
194
- return .discarded
191
+ return try discardEngineReport(reportID, expectedReportIDs: expectedReportIDs, store: store)
192
+ }
193
+ }
194
+
195
+ private func discardEngineReport(
196
+ _ reportID: Int64,
197
+ expectedReportIDs: [Int64],
198
+ store: any CrashReportStoring,
199
+ ) throws -> NativeCrashReplayItem {
200
+ try verifyReportIDs(expectedReportIDs, in: store)
201
+ store.deleteReport(with: reportID)
202
+ guard !store.reportIDs.contains(reportID) else {
203
+ throw NativeCrashError(.reportDeletionFailed)
204
+ }
205
+ recordDiscardedLocked()
206
+ return .discarded
207
+ }
208
+
209
+ /// React Native raises `RCTFatalException` after its JavaScript fatal handler runs.
210
+ /// When the React Native package persisted that JavaScript report first, its last
211
+ /// breadcrumb says so, and this native copy would only repeat the same crash.
212
+ private func repeatsPersistedJavaScriptFatal(_ rawReport: [String: Any]) -> Bool {
213
+ let error = (rawReport["crash"] as? [String: Any])?["error"] as? [String: Any]
214
+ let exception = error?["nsexception"] as? [String: Any]
215
+ guard (exception?["name"] as? String)?.hasPrefix("RCTFatalException") == true else {
216
+ return false
195
217
  }
218
+ let breadcrumbs = NativeCrashBreadcrumbs.captured(in: rawReport).0?.breadcrumbs
219
+ return breadcrumbs?.last?.category == NativeCrashBreadcrumbs.javaScriptFatalCategory
196
220
  }
197
221
 
198
222
  func validatedReportIDs(in store: any CrashReportStoring) throws -> [Int64] {
@@ -34,10 +34,10 @@
34
34
  "swift/logbrew-swift/Sources/LogBrewCrash/CrashStorageDirectory.swift": "7cd566703cbf704dc99155451ee93dcace12c35c805abc09a6dcf23975cf43f9",
35
35
  "swift/logbrew-swift/Sources/LogBrewCrash/NativeArtifactIdentity.swift": "3d785ad717dcf7302451531c18b5e1183983270a6cd78dd543a407e3facc6ae0",
36
36
  "swift/logbrew-swift/Sources/LogBrewCrash/NativeCrashCapture.swift": "0b773a63987b6c694b044e56c0f81878f4f5e71eae3fdd126744cba3cf15aac1",
37
- "swift/logbrew-swift/Sources/LogBrewCrash/NativeCrashCorrelation.swift": "001cba0fc6fa0d03ac058170b3e998b7db415a1b1038acaaec481183f26e8f0d",
37
+ "swift/logbrew-swift/Sources/LogBrewCrash/NativeCrashCorrelation.swift": "e2dca9458194214e231ebdcf475693f9893d708a767d747b210d4aaa4c98a62e",
38
38
  "swift/logbrew-swift/Sources/LogBrewCrash/NativeCrashExceptionEvidence.swift": "ce191e46298d91d87b379528d610caa88b924b15a8dd912b4a164b51eb172a7a",
39
39
  "swift/logbrew-swift/Sources/LogBrewCrash/NativeCrashPublic.swift": "70aa9700efd26d03b9656f1df96876de0b9eb769c03512ec53f667696773954f",
40
- "swift/logbrew-swift/Sources/LogBrewCrash/NativeCrashReplay.swift": "3eb3d93b32cf14de416f56fa30d6d65e6f268b5ec9d1a67081d7525c4efd4f80",
40
+ "swift/logbrew-swift/Sources/LogBrewCrash/NativeCrashReplay.swift": "3767e4504cd555fe8f029d4464901642f971d2e8dd542af375ead80c7a508f2f",
41
41
  "swift/logbrew-swift/Sources/LogBrewCrash/NativeHangIncidentStore.swift": "5a8150083f16d6b495c9c63434809dc5f11f13ebb23211f57151bad62040781b",
42
42
  "swift/logbrew-swift/Sources/LogBrewCrash/NativeHangWatchdog.swift": "37b25904cd6576e20c40500be2c153156403b57ad7b4186a1b6b35b414145ecb",
43
43
  "swift/logbrew-swift/Sources/LogBrewCrash/NativeHangWatchdogContracts.swift": "59f51554d86c326122bb2bdce47c5a7e01996bd61f2b371eba23855032487b9f",
package/metadata.cjs CHANGED
@@ -153,7 +153,7 @@ function runtimeStackFrameFilename(rawLine) {
153
153
  } else if (location.includes("@")) {
154
154
  location = location.slice(location.lastIndexOf("@") + 1);
155
155
  }
156
- const parts = location.split(":");
156
+ const parts = location.replace(/^address at /u, "").split(":");
157
157
  if (parts.length < 3) {
158
158
  return undefined;
159
159
  }
package/native-bridge.cjs CHANGED
@@ -5,6 +5,10 @@ const {
5
5
  } = require("./index.cjs");
6
6
 
7
7
  const DEFAULT_SCOPE_SOURCE = "react-native.native_bridge";
8
+ const ASYNC_BRIDGE_QUEUES = new WeakMap();
9
+ const MAX_PENDING_ASYNC_SCOPES = 128;
10
+ const MAX_ASYNC_SCOPE_METADATA_ENTRIES = 64;
11
+ const MAX_ASYNC_SCOPE_JSON_LENGTH = 8192;
8
12
  const RESERVED_TRACE_METADATA_KEYS = new Set([
9
13
  "parentSpanId",
10
14
  "spanId",
@@ -43,7 +47,13 @@ function createLogBrewNativeBridgeScope({
43
47
 
44
48
  function syncLogBrewNativeBridgeScope(nativeBridge, options = {}) {
45
49
  const payload = createLogBrewNativeBridgeScope(options);
46
- bridgeSync(nativeBridge)(payload);
50
+ const sync = bridgeSync(nativeBridge);
51
+ try {
52
+ sync(payload);
53
+ } catch (error) {
54
+ clearPreservingFailure(nativeBridge);
55
+ throw error;
56
+ }
47
57
  return payload;
48
58
  }
49
59
 
@@ -59,17 +69,104 @@ function withLogBrewNativeBridgeScope(nativeBridge, options, callback) {
59
69
  }
60
70
 
61
71
  const payload = syncLogBrewNativeBridgeScope(nativeBridge, resolvedOptions);
72
+ let result;
62
73
  try {
63
- const result = resolvedCallback(payload);
74
+ result = resolvedCallback(payload);
64
75
  if (result && typeof result.then === "function") {
65
- return Promise.resolve(result).finally(() => clearLogBrewNativeBridgeScope(nativeBridge));
76
+ return Promise.resolve(result).then(
77
+ (value) => {
78
+ clearLogBrewNativeBridgeScope(nativeBridge);
79
+ return value;
80
+ },
81
+ (error) => {
82
+ clearPreservingFailure(nativeBridge);
83
+ throw error;
84
+ }
85
+ );
66
86
  }
67
- clearLogBrewNativeBridgeScope(nativeBridge);
68
- return result;
69
87
  } catch (error) {
70
- clearLogBrewNativeBridgeScope(nativeBridge);
88
+ clearPreservingFailure(nativeBridge);
71
89
  throw error;
72
90
  }
91
+ clearLogBrewNativeBridgeScope(nativeBridge);
92
+ return result;
93
+ }
94
+
95
+ async function withLogBrewNativeBridgeScopeAsync(nativeBridge, options, callback) {
96
+ const resolvedOptions = typeof options === "function" ? {} : options ?? {};
97
+ const resolvedCallback = typeof options === "function" ? options : callback;
98
+ if (typeof resolvedCallback !== "function") {
99
+ throw new SdkError("configuration_error", "withLogBrewNativeBridgeScopeAsync requires a callback");
100
+ }
101
+ if (nativeBridge === null || (typeof nativeBridge !== "object" && typeof nativeBridge !== "function")) {
102
+ throw new SdkError("configuration_error", "async native bridge scope requires an adapter object or function");
103
+ }
104
+ const queue = ASYNC_BRIDGE_QUEUES.get(nativeBridge) ?? { pending: 0, tail: Promise.resolve() };
105
+ if (queue.pending >= MAX_PENDING_ASYNC_SCOPES) {
106
+ throw new SdkError("native_scope_queue_full", "async native bridge scope queue is full");
107
+ }
108
+ queue.pending += 1;
109
+ ASYNC_BRIDGE_QUEUES.set(nativeBridge, queue);
110
+ let sync;
111
+ let clear;
112
+ let payload;
113
+ try {
114
+ sync = bridgeSync(nativeBridge);
115
+ clear = bridgeClear(nativeBridge, true);
116
+ payload = createLogBrewNativeBridgeScope(resolvedOptions);
117
+ if (Object.keys(payload.metadata).length > MAX_ASYNC_SCOPE_METADATA_ENTRIES
118
+ || JSON.stringify(payload).length > MAX_ASYNC_SCOPE_JSON_LENGTH) {
119
+ throw new SdkError("native_scope_too_large", "async native bridge scope exceeds its payload limit");
120
+ }
121
+ } catch (error) {
122
+ releaseAsyncScopeReservation(nativeBridge, queue);
123
+ throw error;
124
+ }
125
+ return runQueuedNativeBridgeScope(nativeBridge, queue, sync, clear, payload, resolvedCallback);
126
+ }
127
+
128
+ async function runQueuedNativeBridgeScope(nativeBridge, queue, sync, clear, payload, callback) {
129
+ const previous = queue.tail;
130
+ let release;
131
+ const completion = new Promise((resolve) => { release = resolve; });
132
+ const turn = previous.then(() => completion);
133
+ queue.tail = turn;
134
+ await previous;
135
+ try {
136
+ await clear();
137
+ let result;
138
+ try {
139
+ await sync(payload);
140
+ result = await callback(payload);
141
+ } catch (error) {
142
+ try {
143
+ await clear();
144
+ } catch {
145
+ // Preserve the setter or callback failure after attempting scope clear.
146
+ }
147
+ throw error;
148
+ }
149
+ await clear();
150
+ return result;
151
+ } finally {
152
+ release();
153
+ releaseAsyncScopeReservation(nativeBridge, queue);
154
+ }
155
+ }
156
+
157
+ function releaseAsyncScopeReservation(nativeBridge, queue) {
158
+ queue.pending -= 1;
159
+ if (queue.pending === 0) {
160
+ ASYNC_BRIDGE_QUEUES.delete(nativeBridge);
161
+ }
162
+ }
163
+
164
+ function clearPreservingFailure(nativeBridge) {
165
+ try {
166
+ clearLogBrewNativeBridgeScope(nativeBridge);
167
+ } catch {
168
+ // Keep the original failure when clearing the scope also fails.
169
+ }
73
170
  }
74
171
 
75
172
  function bridgeSync(nativeBridge) {
@@ -88,7 +185,7 @@ function bridgeSync(nativeBridge) {
88
185
  );
89
186
  }
90
187
 
91
- function bridgeClear(nativeBridge) {
188
+ function bridgeClear(nativeBridge, required = false) {
92
189
  if (nativeBridge && typeof nativeBridge.clearLogBrewScope === "function") {
93
190
  return nativeBridge.clearLogBrewScope.bind(nativeBridge);
94
191
  }
@@ -98,6 +195,12 @@ function bridgeClear(nativeBridge) {
98
195
  if (typeof nativeBridge === "function") {
99
196
  return () => nativeBridge(undefined);
100
197
  }
198
+ if (required) {
199
+ throw new SdkError(
200
+ "configuration_error",
201
+ "async LogBrew native bridge scope requires clearLogBrewScope or clearLogBrewTraceContext"
202
+ );
203
+ }
101
204
  return () => {};
102
205
  }
103
206
 
@@ -121,7 +224,8 @@ const defaultExport = {
121
224
  clearLogBrewNativeBridgeScope,
122
225
  createLogBrewNativeBridgeScope,
123
226
  syncLogBrewNativeBridgeScope,
124
- withLogBrewNativeBridgeScope
227
+ withLogBrewNativeBridgeScope,
228
+ withLogBrewNativeBridgeScopeAsync
125
229
  };
126
230
 
127
231
  module.exports = { ...defaultExport, default: defaultExport };
@@ -30,6 +30,16 @@ export type LogBrewNativeBridgeScopeInput = {
30
30
  trace?: ReactNativeTraceInput;
31
31
  };
32
32
 
33
+ export type LogBrewAsyncNativeBridgeLike =
34
+ | ((scope: LogBrewNativeBridgeScope | undefined) => void | PromiseLike<void>)
35
+ | ({
36
+ setLogBrewScope?: (scope: LogBrewNativeBridgeScope) => void | PromiseLike<void>;
37
+ syncLogBrewScope?: (scope: LogBrewNativeBridgeScope) => void | PromiseLike<void>;
38
+ } & (
39
+ | { clearLogBrewScope: () => void | PromiseLike<void> }
40
+ | { clearLogBrewTraceContext: () => void | PromiseLike<void> }
41
+ ));
42
+
33
43
  export declare function createLogBrewNativeBridgeScope(
34
44
  input?: LogBrewNativeBridgeScopeInput
35
45
  ): LogBrewNativeBridgeScope;
@@ -50,11 +60,35 @@ export declare function withLogBrewNativeBridgeScope<TResult>(
50
60
  callback: (scope: LogBrewNativeBridgeScope) => TResult
51
61
  ): TResult;
52
62
 
63
+ /**
64
+ * Serializes calls to this helper for the same adapter object or function.
65
+ * Clears native scope before and after each callback, including rejection.
66
+ * Snapshots input at enqueue time and awaits native setters and clear methods.
67
+ * Allows 128 active or queued calls per adapter; excess calls reject with
68
+ * native_scope_queue_full before input is snapshotted. Each scope permits at
69
+ * most 64 metadata entries, including derived fields, and 8192 UTF-16 code
70
+ * units in its JSON representation. Larger scopes reject with native_scope_too_large.
71
+ * External scope writes and the synchronous helper do not share this queue.
72
+ * Do not await another call on the same bridge from inside its callback.
73
+ * An unsettled callback keeps its scope and queue slot. There is no timeout or
74
+ * cancellation contract; queued callbacks wait until it settles and native scope is cleared.
75
+ */
76
+ export declare function withLogBrewNativeBridgeScopeAsync<TResult>(
77
+ nativeBridge: LogBrewAsyncNativeBridgeLike,
78
+ callback: (scope: LogBrewNativeBridgeScope) => TResult
79
+ ): Promise<Awaited<TResult>>;
80
+ export declare function withLogBrewNativeBridgeScopeAsync<TResult>(
81
+ nativeBridge: LogBrewAsyncNativeBridgeLike,
82
+ input: LogBrewNativeBridgeScopeInput,
83
+ callback: (scope: LogBrewNativeBridgeScope) => TResult
84
+ ): Promise<Awaited<TResult>>;
85
+
53
86
  declare const defaultExport: {
54
87
  clearLogBrewNativeBridgeScope: typeof clearLogBrewNativeBridgeScope;
55
88
  createLogBrewNativeBridgeScope: typeof createLogBrewNativeBridgeScope;
56
89
  syncLogBrewNativeBridgeScope: typeof syncLogBrewNativeBridgeScope;
57
90
  withLogBrewNativeBridgeScope: typeof withLogBrewNativeBridgeScope;
91
+ withLogBrewNativeBridgeScopeAsync: typeof withLogBrewNativeBridgeScopeAsync;
58
92
  };
59
93
 
60
94
  export default defaultExport;
@@ -30,6 +30,16 @@ export type LogBrewNativeBridgeScopeInput = {
30
30
  trace?: ReactNativeTraceInput;
31
31
  };
32
32
 
33
+ export type LogBrewAsyncNativeBridgeLike =
34
+ | ((scope: LogBrewNativeBridgeScope | undefined) => void | PromiseLike<void>)
35
+ | ({
36
+ setLogBrewScope?: (scope: LogBrewNativeBridgeScope) => void | PromiseLike<void>;
37
+ syncLogBrewScope?: (scope: LogBrewNativeBridgeScope) => void | PromiseLike<void>;
38
+ } & (
39
+ | { clearLogBrewScope: () => void | PromiseLike<void> }
40
+ | { clearLogBrewTraceContext: () => void | PromiseLike<void> }
41
+ ));
42
+
33
43
  export declare function createLogBrewNativeBridgeScope(
34
44
  input?: LogBrewNativeBridgeScopeInput
35
45
  ): LogBrewNativeBridgeScope;
@@ -50,11 +60,35 @@ export declare function withLogBrewNativeBridgeScope<TResult>(
50
60
  callback: (scope: LogBrewNativeBridgeScope) => TResult
51
61
  ): TResult;
52
62
 
63
+ /**
64
+ * Serializes calls to this helper for the same adapter object or function.
65
+ * Clears native scope before and after each callback, including rejection.
66
+ * Snapshots input at enqueue time and awaits native setters and clear methods.
67
+ * Allows 128 active or queued calls per adapter; excess calls reject with
68
+ * native_scope_queue_full before input is snapshotted. Each scope permits at
69
+ * most 64 metadata entries, including derived fields, and 8192 UTF-16 code
70
+ * units in its JSON representation. Larger scopes reject with native_scope_too_large.
71
+ * External scope writes and the synchronous helper do not share this queue.
72
+ * Do not await another call on the same bridge from inside its callback.
73
+ * An unsettled callback keeps its scope and queue slot. There is no timeout or
74
+ * cancellation contract; queued callbacks wait until it settles and native scope is cleared.
75
+ */
76
+ export declare function withLogBrewNativeBridgeScopeAsync<TResult>(
77
+ nativeBridge: LogBrewAsyncNativeBridgeLike,
78
+ callback: (scope: LogBrewNativeBridgeScope) => TResult
79
+ ): Promise<Awaited<TResult>>;
80
+ export declare function withLogBrewNativeBridgeScopeAsync<TResult>(
81
+ nativeBridge: LogBrewAsyncNativeBridgeLike,
82
+ input: LogBrewNativeBridgeScopeInput,
83
+ callback: (scope: LogBrewNativeBridgeScope) => TResult
84
+ ): Promise<Awaited<TResult>>;
85
+
53
86
  declare const defaultExport: {
54
87
  clearLogBrewNativeBridgeScope: typeof clearLogBrewNativeBridgeScope;
55
88
  createLogBrewNativeBridgeScope: typeof createLogBrewNativeBridgeScope;
56
89
  syncLogBrewNativeBridgeScope: typeof syncLogBrewNativeBridgeScope;
57
90
  withLogBrewNativeBridgeScope: typeof withLogBrewNativeBridgeScope;
91
+ withLogBrewNativeBridgeScopeAsync: typeof withLogBrewNativeBridgeScopeAsync;
58
92
  };
59
93
 
60
94
  export default defaultExport;
package/native-bridge.js CHANGED
@@ -4,7 +4,8 @@ export const {
4
4
  clearLogBrewNativeBridgeScope,
5
5
  createLogBrewNativeBridgeScope,
6
6
  syncLogBrewNativeBridgeScope,
7
- withLogBrewNativeBridgeScope
7
+ withLogBrewNativeBridgeScope,
8
+ withLogBrewNativeBridgeScopeAsync
8
9
  } = runtime;
9
10
 
10
11
  export default runtime.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logbrew/react-native",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "description": "React Native offline delivery, native diagnostics, screen, error, trace, action, and network timeline helpers for LogBrew.",
5
5
  "type": "module",
6
6
  "main": "./index.cjs",
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  const { createReactNativeErrorEvent } = require("./index.cjs");
4
+ const { captureIssueWithAdmission } = require("./fatal-replay.cjs");
4
5
 
5
6
  const AUTOMATIC_MESSAGE = "Unhandled Promise rejection";
6
7
  const DEFAULT_MAX_TRACKED_REJECTIONS = 128;
@@ -101,7 +102,16 @@ function createPromiseRejectionHandlers(options, mechanism) {
101
102
  emitStateDiagnostic(state, onDiagnostic, "promise_rejection_id_unavailable");
102
103
  }
103
104
  const event = createEvent(mechanism);
104
- issue.call(client, event.id, event.timestamp, event.attributes);
105
+ const admission = captureIssueWithAdmission(client, issue, event.id, event.timestamp, event.attributes);
106
+ if (admission !== "admitted") {
107
+ state.lastOutcome = admission === "unavailable"
108
+ ? "admission_unavailable"
109
+ : admission === "filtered" ? "filtered" : "capture_failed";
110
+ emitStateDiagnostic(state, onDiagnostic, admission === "unavailable"
111
+ ? "promise_rejection_admission_unavailable"
112
+ : admission === "filtered" ? "promise_rejection_filtered" : "promise_rejection_capture_failed");
113
+ return;
114
+ }
105
115
  state.capturedEvents = incrementBounded(state.capturedEvents);
106
116
 
107
117
  if (key === undefined) {