@sentry/cloudflare 10.53.1 → 10.55.0

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.
Files changed (172) hide show
  1. package/build/cjs/async.js +4 -30
  2. package/build/cjs/async.js.map +1 -1
  3. package/build/cjs/client.js +31 -58
  4. package/build/cjs/client.js.map +1 -1
  5. package/build/cjs/d1.js +26 -80
  6. package/build/cjs/d1.js.map +1 -1
  7. package/build/cjs/debug-build.js +0 -5
  8. package/build/cjs/debug-build.js.map +1 -1
  9. package/build/cjs/durableobject.js +44 -131
  10. package/build/cjs/durableobject.js.map +1 -1
  11. package/build/cjs/flush.js +53 -34
  12. package/build/cjs/flush.js.map +1 -1
  13. package/build/cjs/instrument.js +7 -48
  14. package/build/cjs/instrument.js.map +1 -1
  15. package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js +9 -34
  16. package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  17. package/build/cjs/instrumentations/instrumentDurableObjectStorage.js +20 -54
  18. package/build/cjs/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  19. package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js +12 -66
  20. package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  21. package/build/cjs/instrumentations/worker/instrumentEmail.js +21 -43
  22. package/build/cjs/instrumentations/worker/instrumentEmail.js.map +1 -1
  23. package/build/cjs/instrumentations/worker/instrumentEnv.js +12 -42
  24. package/build/cjs/instrumentations/worker/instrumentEnv.js.map +1 -1
  25. package/build/cjs/instrumentations/worker/instrumentFetch.js +20 -34
  26. package/build/cjs/instrumentations/worker/instrumentFetch.js.map +1 -1
  27. package/build/cjs/instrumentations/worker/instrumentFetcher.js +5 -19
  28. package/build/cjs/instrumentations/worker/instrumentFetcher.js.map +1 -1
  29. package/build/cjs/instrumentations/worker/instrumentQueue.js +30 -62
  30. package/build/cjs/instrumentations/worker/instrumentQueue.js.map +1 -1
  31. package/build/cjs/instrumentations/worker/instrumentQueueProducer.js +31 -57
  32. package/build/cjs/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  33. package/build/cjs/instrumentations/worker/instrumentScheduled.js +25 -54
  34. package/build/cjs/instrumentations/worker/instrumentScheduled.js.map +1 -1
  35. package/build/cjs/instrumentations/worker/instrumentTail.js +16 -43
  36. package/build/cjs/instrumentations/worker/instrumentTail.js.map +1 -1
  37. package/build/cjs/integrations/fetch.js +24 -56
  38. package/build/cjs/integrations/fetch.js.map +1 -1
  39. package/build/cjs/integrations/hono.js +7 -38
  40. package/build/cjs/integrations/hono.js.map +1 -1
  41. package/build/cjs/integrations/httpServer.js +6 -39
  42. package/build/cjs/integrations/httpServer.js.map +1 -1
  43. package/build/cjs/integrations/tracing/vercelai.js +3 -31
  44. package/build/cjs/integrations/tracing/vercelai.js.map +1 -1
  45. package/build/cjs/opentelemetry/tracer.js +17 -45
  46. package/build/cjs/opentelemetry/tracer.js.map +1 -1
  47. package/build/cjs/options.js +10 -46
  48. package/build/cjs/options.js.map +1 -1
  49. package/build/cjs/pages-plugin.js +9 -42
  50. package/build/cjs/pages-plugin.js.map +1 -1
  51. package/build/cjs/request.js +22 -68
  52. package/build/cjs/request.js.map +1 -1
  53. package/build/cjs/scope-utils.js +4 -15
  54. package/build/cjs/scope-utils.js.map +1 -1
  55. package/build/cjs/sdk.js +8 -25
  56. package/build/cjs/sdk.js.map +1 -1
  57. package/build/cjs/transport.js +14 -48
  58. package/build/cjs/transport.js.map +1 -1
  59. package/build/cjs/utils/instrumentContext.js +16 -52
  60. package/build/cjs/utils/instrumentContext.js.map +1 -1
  61. package/build/cjs/utils/isBinding.js +3 -23
  62. package/build/cjs/utils/isBinding.js.map +1 -1
  63. package/build/cjs/utils/isCloudflareClass.js +2 -8
  64. package/build/cjs/utils/isCloudflareClass.js.map +1 -1
  65. package/build/cjs/utils/rpcMeta.js +8 -32
  66. package/build/cjs/utils/rpcMeta.js.map +1 -1
  67. package/build/cjs/utils/rpcOptions.js +9 -32
  68. package/build/cjs/utils/rpcOptions.js.map +1 -1
  69. package/build/cjs/utils/streaming.js +3 -29
  70. package/build/cjs/utils/streaming.js.map +1 -1
  71. package/build/cjs/utils/traceLinks.js +8 -33
  72. package/build/cjs/utils/traceLinks.js.map +1 -1
  73. package/build/cjs/vendor/stacktrace.js +6 -27
  74. package/build/cjs/vendor/stacktrace.js.map +1 -1
  75. package/build/cjs/withSentry.js +16 -47
  76. package/build/cjs/withSentry.js.map +1 -1
  77. package/build/cjs/workflows.js +40 -100
  78. package/build/cjs/workflows.js.map +1 -1
  79. package/build/cjs/wrapMethodWithSentry.js +110 -167
  80. package/build/cjs/wrapMethodWithSentry.js.map +1 -1
  81. package/build/esm/async.js +4 -30
  82. package/build/esm/async.js.map +1 -1
  83. package/build/esm/client.js +31 -58
  84. package/build/esm/client.js.map +1 -1
  85. package/build/esm/d1.js +26 -80
  86. package/build/esm/d1.js.map +1 -1
  87. package/build/esm/debug-build.js +0 -5
  88. package/build/esm/debug-build.js.map +1 -1
  89. package/build/esm/durableobject.js +44 -131
  90. package/build/esm/durableobject.js.map +1 -1
  91. package/build/esm/flush.js +53 -35
  92. package/build/esm/flush.js.map +1 -1
  93. package/build/esm/instrument.js +7 -48
  94. package/build/esm/instrument.js.map +1 -1
  95. package/build/esm/instrumentations/instrumentDurableObjectNamespace.js +9 -34
  96. package/build/esm/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
  97. package/build/esm/instrumentations/instrumentDurableObjectStorage.js +20 -54
  98. package/build/esm/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
  99. package/build/esm/instrumentations/instrumentWorkerEntrypoint.js +12 -66
  100. package/build/esm/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
  101. package/build/esm/instrumentations/worker/instrumentEmail.js +21 -43
  102. package/build/esm/instrumentations/worker/instrumentEmail.js.map +1 -1
  103. package/build/esm/instrumentations/worker/instrumentEnv.js +12 -42
  104. package/build/esm/instrumentations/worker/instrumentEnv.js.map +1 -1
  105. package/build/esm/instrumentations/worker/instrumentFetch.js +20 -34
  106. package/build/esm/instrumentations/worker/instrumentFetch.js.map +1 -1
  107. package/build/esm/instrumentations/worker/instrumentFetcher.js +5 -19
  108. package/build/esm/instrumentations/worker/instrumentFetcher.js.map +1 -1
  109. package/build/esm/instrumentations/worker/instrumentQueue.js +30 -62
  110. package/build/esm/instrumentations/worker/instrumentQueue.js.map +1 -1
  111. package/build/esm/instrumentations/worker/instrumentQueueProducer.js +31 -57
  112. package/build/esm/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
  113. package/build/esm/instrumentations/worker/instrumentScheduled.js +25 -54
  114. package/build/esm/instrumentations/worker/instrumentScheduled.js.map +1 -1
  115. package/build/esm/instrumentations/worker/instrumentTail.js +16 -43
  116. package/build/esm/instrumentations/worker/instrumentTail.js.map +1 -1
  117. package/build/esm/integrations/fetch.js +24 -56
  118. package/build/esm/integrations/fetch.js.map +1 -1
  119. package/build/esm/integrations/hono.js +7 -38
  120. package/build/esm/integrations/hono.js.map +1 -1
  121. package/build/esm/integrations/httpServer.js +6 -39
  122. package/build/esm/integrations/httpServer.js.map +1 -1
  123. package/build/esm/integrations/tracing/vercelai.js +3 -31
  124. package/build/esm/integrations/tracing/vercelai.js.map +1 -1
  125. package/build/esm/opentelemetry/tracer.js +17 -45
  126. package/build/esm/opentelemetry/tracer.js.map +1 -1
  127. package/build/esm/options.js +10 -46
  128. package/build/esm/options.js.map +1 -1
  129. package/build/esm/package.json +1 -1
  130. package/build/esm/pages-plugin.js +9 -42
  131. package/build/esm/pages-plugin.js.map +1 -1
  132. package/build/esm/request.js +23 -69
  133. package/build/esm/request.js.map +1 -1
  134. package/build/esm/scope-utils.js +4 -15
  135. package/build/esm/scope-utils.js.map +1 -1
  136. package/build/esm/sdk.js +8 -25
  137. package/build/esm/sdk.js.map +1 -1
  138. package/build/esm/transport.js +14 -48
  139. package/build/esm/transport.js.map +1 -1
  140. package/build/esm/utils/instrumentContext.js +16 -52
  141. package/build/esm/utils/instrumentContext.js.map +1 -1
  142. package/build/esm/utils/isBinding.js +3 -23
  143. package/build/esm/utils/isBinding.js.map +1 -1
  144. package/build/esm/utils/isCloudflareClass.js +2 -8
  145. package/build/esm/utils/isCloudflareClass.js.map +1 -1
  146. package/build/esm/utils/rpcMeta.js +8 -32
  147. package/build/esm/utils/rpcMeta.js.map +1 -1
  148. package/build/esm/utils/rpcOptions.js +9 -32
  149. package/build/esm/utils/rpcOptions.js.map +1 -1
  150. package/build/esm/utils/streaming.js +3 -29
  151. package/build/esm/utils/streaming.js.map +1 -1
  152. package/build/esm/utils/traceLinks.js +8 -33
  153. package/build/esm/utils/traceLinks.js.map +1 -1
  154. package/build/esm/vendor/stacktrace.js +6 -27
  155. package/build/esm/vendor/stacktrace.js.map +1 -1
  156. package/build/esm/withSentry.js +16 -47
  157. package/build/esm/withSentry.js.map +1 -1
  158. package/build/esm/workflows.js +40 -100
  159. package/build/esm/workflows.js.map +1 -1
  160. package/build/esm/wrapMethodWithSentry.js +110 -167
  161. package/build/esm/wrapMethodWithSentry.js.map +1 -1
  162. package/build/types/client.d.ts.map +1 -1
  163. package/build/types/flush.d.ts +15 -0
  164. package/build/types/flush.d.ts.map +1 -1
  165. package/build/types/instrumentations/worker/instrumentFetch.d.ts.map +1 -1
  166. package/build/types/integrations/hono.d.ts +3 -0
  167. package/build/types/integrations/hono.d.ts.map +1 -1
  168. package/build/types/pages-plugin.d.ts.map +1 -1
  169. package/build/types/request.d.ts.map +1 -1
  170. package/build/types-ts3.8/flush.d.ts +15 -0
  171. package/build/types-ts3.8/integrations/hono.d.ts +3 -0
  172. package/package.json +2 -2
@@ -5,89 +5,102 @@ import { init } from './sdk.js';
5
5
  import { extractRpcMeta } from './utils/rpcMeta.js';
6
6
  import { storeSpanContext, getStoredSpanContext, buildSpanLinks } from './utils/traceLinks.js';
7
7
 
8
- /** Extended DurableObjectState with originalStorage exposed by instrumentContext */
9
-
10
- /**
11
- * Wraps a method with Sentry error tracking and optional tracing.
12
- * Supports starting new traces and linking to previous invocations via Durable Object storage.
13
- *
14
- * @param wrapperOptions - The options for the wrapper.
15
- * @param handler - The method to wrap.
16
- * @param callback - The callback to call.
17
- * @param noMark - Whether to mark the method as instrumented.
18
- * @returns The wrapped method.
19
- */
20
- function wrapMethodWithSentry(
21
- wrapperOptions,
22
- handler,
23
- callback,
24
- noMark,
25
- ) {
8
+ function wrapMethodWithSentry(wrapperOptions, handler, callback, noMark) {
26
9
  return ensureInstrumented(
27
10
  handler,
28
- original =>
29
- new Proxy(original, {
30
- apply(target, thisArg, rawArgs) {
31
- const { startNewTrace: startNewTrace$1 } = wrapperOptions;
32
-
33
- // For RPC methods, extract Sentry trace context from the trailing argument.
34
- // The caller side (instrumentDurableObjectStub / JSRPC proxy) appends it;
35
- // we strip it here so the user's method never sees it.
36
- let args = rawArgs;
37
- let rpcMeta;
38
-
39
- if (wrapperOptions.spanOp === 'rpc') {
40
- const extracted = extractRpcMeta(rawArgs);
41
- args = extracted.args;
42
- rpcMeta = extracted.rpcMeta;
11
+ (original) => new Proxy(original, {
12
+ apply(target, thisArg, rawArgs) {
13
+ const { startNewTrace: startNewTrace$1 } = wrapperOptions;
14
+ let args = rawArgs;
15
+ let rpcMeta;
16
+ if (wrapperOptions.spanOp === "rpc") {
17
+ const extracted = extractRpcMeta(rawArgs);
18
+ args = extracted.args;
19
+ rpcMeta = extracted.rpcMeta;
20
+ }
21
+ const currentClient = getClient();
22
+ const sentryWithScope = startNewTrace$1 ? withIsolationScope : currentClient ? withScope : withIsolationScope;
23
+ const wrappedFunction = (scope) => {
24
+ const context = wrapperOptions.context;
25
+ const waitUntil = context?.waitUntil?.bind?.(context);
26
+ const storage = context && "originalStorage" in context ? context.originalStorage : void 0;
27
+ let scopeClient = scope.getClient();
28
+ if (startNewTrace$1 || !scopeClient?.getTransport()) {
29
+ const client = init({
30
+ ...wrapperOptions.options,
31
+ ctx: context
32
+ });
33
+ scope.setClient(client);
34
+ scopeClient = client;
43
35
  }
44
-
45
- // For startNewTrace, always use withIsolationScope to ensure a fresh scope
46
- // Otherwise, use existing client's scope or isolation scope
47
- const currentClient = getClient();
48
- const sentryWithScope = startNewTrace$1 ? withIsolationScope : currentClient ? withScope : withIsolationScope;
49
-
50
- const wrappedFunction = (scope) => {
51
- // In certain situations, the passed context can become undefined.
52
- // For example, for Astro while prerendering pages at build time.
53
- // see: https://github.com/getsentry/sentry-javascript/issues/13217
54
- const context = wrapperOptions.context;
55
-
56
- const waitUntil = context?.waitUntil?.bind?.(context);
57
- const storage = context && 'originalStorage' in context ? context.originalStorage : undefined;
58
-
59
- let scopeClient = scope.getClient();
60
- // Check if client exists AND is still usable (transport not disposed)
61
- // This handles the case where a previous handler disposed the client
62
- // but the scope still holds a reference to it (e.g., alarm handlers in Durable Objects)
63
- // For startNewTrace, always create a fresh client
64
- if (startNewTrace$1 || !scopeClient?.getTransport()) {
65
- const client = init({
66
- ...wrapperOptions.options,
67
- ctx: context ,
36
+ const clientToDispose = scopeClient;
37
+ const methodName = wrapperOptions.spanName || "unknown";
38
+ const teardown = async () => {
39
+ if (startNewTrace$1 && storage) {
40
+ await storeSpanContext(storage, methodName);
41
+ }
42
+ await flushAndDispose(clientToDispose);
43
+ };
44
+ if (!wrapperOptions.spanName) {
45
+ try {
46
+ if (callback) {
47
+ callback(...args);
48
+ }
49
+ const result = Reflect.apply(target, thisArg, args);
50
+ if (isThenable(result)) {
51
+ return result.then(
52
+ (res) => {
53
+ waitUntil?.(teardown());
54
+ return res;
55
+ },
56
+ (e) => {
57
+ captureException(e, {
58
+ mechanism: {
59
+ type: "auto.faas.cloudflare.durable_object",
60
+ handled: false
61
+ }
62
+ });
63
+ waitUntil?.(teardown());
64
+ throw e;
65
+ }
66
+ );
67
+ } else {
68
+ waitUntil?.(teardown());
69
+ return result;
70
+ }
71
+ } catch (e) {
72
+ captureException(e, {
73
+ mechanism: {
74
+ type: "auto.faas.cloudflare.durable_object",
75
+ handled: false
76
+ }
68
77
  });
69
- scope.setClient(client);
70
- scopeClient = client;
78
+ waitUntil?.(teardown());
79
+ throw e;
71
80
  }
72
-
73
- const clientToDispose = scopeClient;
74
- const methodName = wrapperOptions.spanName || 'unknown';
75
-
76
- const teardown = async () => {
81
+ }
82
+ const attributes = wrapperOptions.spanOp ? {
83
+ [SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,
84
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.faas.cloudflare.durable_object"
85
+ } : {};
86
+ const executeSpan = () => {
87
+ return startSpan({ name: methodName, attributes }, (span) => {
77
88
  if (startNewTrace$1 && storage) {
78
- await storeSpanContext(storage, methodName);
89
+ waitUntil?.(
90
+ getStoredSpanContext(storage, methodName).then((storedContext) => {
91
+ if (storedContext) {
92
+ span.addLinks(buildSpanLinks(storedContext));
93
+ const sampledFlag = storedContext.sampled ? "1" : "0";
94
+ span.setAttribute(
95
+ "sentry.previous_trace",
96
+ `${storedContext.traceId}-${storedContext.spanId}-${sampledFlag}`
97
+ );
98
+ }
99
+ })
100
+ );
79
101
  }
80
- await flushAndDispose(clientToDispose);
81
- };
82
-
83
- if (!wrapperOptions.spanName) {
84
102
  try {
85
- if (callback) {
86
- callback(...args);
87
- }
88
-
89
103
  const result = Reflect.apply(target, thisArg, args);
90
-
91
104
  if (isThenable(result)) {
92
105
  return result.then(
93
106
  (res) => {
@@ -97,13 +110,13 @@ function wrapMethodWithSentry(
97
110
  (e) => {
98
111
  captureException(e, {
99
112
  mechanism: {
100
- type: 'auto.faas.cloudflare.durable_object',
101
- handled: false,
102
- },
113
+ type: "auto.faas.cloudflare.durable_object",
114
+ handled: false
115
+ }
103
116
  });
104
117
  waitUntil?.(teardown());
105
118
  throw e;
106
- },
119
+ }
107
120
  );
108
121
  } else {
109
122
  waitUntil?.(teardown());
@@ -112,100 +125,30 @@ function wrapMethodWithSentry(
112
125
  } catch (e) {
113
126
  captureException(e, {
114
127
  mechanism: {
115
- type: 'auto.faas.cloudflare.durable_object',
116
- handled: false,
117
- },
128
+ type: "auto.faas.cloudflare.durable_object",
129
+ handled: false
130
+ }
118
131
  });
119
132
  waitUntil?.(teardown());
120
133
  throw e;
121
134
  }
122
- }
123
-
124
- const attributes = wrapperOptions.spanOp
125
- ? {
126
- [SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,
127
- [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.durable_object',
128
- }
129
- : {};
130
-
131
- const executeSpan = () => {
132
- return startSpan({ name: methodName, attributes }, span => {
133
- // When linking to previous trace, fetch the stored context and add links asynchronously
134
- // This avoids blocking the response while fetching from storage
135
- if (startNewTrace$1 && storage) {
136
- waitUntil?.(
137
- getStoredSpanContext(storage, methodName).then(storedContext => {
138
- if (storedContext) {
139
- span.addLinks(buildSpanLinks(storedContext));
140
- // TODO: Remove this once EAP can store span links. We currently only set this attribute so that we
141
- // can obtain the previous trace information from the EAP store. Long-term, EAP will handle
142
- // span links and then we should remove this again. Also throwing in a TODO(v11), to remind us
143
- // to check this at v11 time :)
144
- const sampledFlag = storedContext.sampled ? '1' : '0';
145
- span.setAttribute(
146
- 'sentry.previous_trace',
147
- `${storedContext.traceId}-${storedContext.spanId}-${sampledFlag}`,
148
- );
149
- }
150
- }),
151
- );
152
- }
153
-
154
- try {
155
- const result = Reflect.apply(target, thisArg, args);
156
-
157
- if (isThenable(result)) {
158
- return result.then(
159
- (res) => {
160
- waitUntil?.(teardown());
161
- return res;
162
- },
163
- (e) => {
164
- captureException(e, {
165
- mechanism: {
166
- type: 'auto.faas.cloudflare.durable_object',
167
- handled: false,
168
- },
169
- });
170
- waitUntil?.(teardown());
171
- throw e;
172
- },
173
- );
174
- } else {
175
- waitUntil?.(teardown());
176
- return result;
177
- }
178
- } catch (e) {
179
- captureException(e, {
180
- mechanism: {
181
- type: 'auto.faas.cloudflare.durable_object',
182
- handled: false,
183
- },
184
- });
185
- waitUntil?.(teardown());
186
- throw e;
187
- }
188
- });
189
- };
190
-
191
- if (rpcMeta) {
192
- return continueTrace(
193
- { sentryTrace: rpcMeta['sentry-trace'] || '', baggage: rpcMeta.baggage || '' },
194
- executeSpan,
195
- );
196
- }
197
-
198
- if (startNewTrace$1) {
199
- return startNewTrace(() => executeSpan());
200
- }
201
-
202
- return executeSpan();
135
+ });
203
136
  };
204
-
205
- return sentryWithScope(wrappedFunction);
206
- },
207
- }),
208
- noMark,
137
+ if (rpcMeta) {
138
+ return continueTrace(
139
+ { sentryTrace: rpcMeta["sentry-trace"] || "", baggage: rpcMeta.baggage || "" },
140
+ executeSpan
141
+ );
142
+ }
143
+ if (startNewTrace$1) {
144
+ return startNewTrace(() => executeSpan());
145
+ }
146
+ return executeSpan();
147
+ };
148
+ return sentryWithScope(wrappedFunction);
149
+ }
150
+ }),
151
+ noMark
209
152
  );
210
153
  }
211
154
 
@@ -1 +1 @@
1
- {"version":3,"file":"wrapMethodWithSentry.js","sources":["../../src/wrapMethodWithSentry.ts"],"sourcesContent":["import type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport type { SerializedTraceData } from '@sentry/core';\nimport {\n captureException,\n continueTrace,\n getClient,\n isThenable,\n type Scope,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startNewTrace as startNewTraceCore,\n startSpan,\n withIsolationScope,\n withScope,\n} from '@sentry/core';\nimport type { CloudflareOptions } from './client';\nimport { flushAndDispose } from './flush';\nimport { ensureInstrumented } from './instrument';\nimport { init } from './sdk';\nimport { extractRpcMeta } from './utils/rpcMeta';\nimport { buildSpanLinks, getStoredSpanContext, storeSpanContext } from './utils/traceLinks';\n\n/** Extended DurableObjectState with originalStorage exposed by instrumentContext */\ninterface InstrumentedDurableObjectState extends DurableObjectState {\n originalStorage?: DurableObjectStorage;\n}\n\ntype MethodWrapperOptions = {\n spanName?: string;\n spanOp?: string;\n options: CloudflareOptions;\n context: ExecutionContext | InstrumentedDurableObjectState;\n /**\n * If true, starts a fresh trace instead of inheriting from a parent trace.\n * Useful for scheduled/independent invocations like alarms.\n *\n * If true, it also stores the current span context and links to the previous invocation's span.\n * Uses Durable Object storage to persist the link. The link is set asynchronously via `span.addLinks()`\n * in a `waitUntil` to avoid blocking.\n *\n * @default false\n */\n startNewTrace?: boolean;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UncheckedMethod = (...args: any[]) => any;\ntype OriginalMethod = UncheckedMethod;\n\n/**\n * Wraps a method with Sentry error tracking and optional tracing.\n * Supports starting new traces and linking to previous invocations via Durable Object storage.\n *\n * @param wrapperOptions - The options for the wrapper.\n * @param handler - The method to wrap.\n * @param callback - The callback to call.\n * @param noMark - Whether to mark the method as instrumented.\n * @returns The wrapped method.\n */\nexport function wrapMethodWithSentry<T extends OriginalMethod>(\n wrapperOptions: MethodWrapperOptions,\n handler: T,\n callback?: (...args: Parameters<T>) => void,\n noMark?: true,\n): T {\n return ensureInstrumented(\n handler,\n original =>\n new Proxy(original, {\n apply(target, thisArg, rawArgs: Parameters<T>) {\n const { startNewTrace } = wrapperOptions;\n\n // For RPC methods, extract Sentry trace context from the trailing argument.\n // The caller side (instrumentDurableObjectStub / JSRPC proxy) appends it;\n // we strip it here so the user's method never sees it.\n let args = rawArgs;\n let rpcMeta: SerializedTraceData | undefined;\n\n if (wrapperOptions.spanOp === 'rpc') {\n const extracted = extractRpcMeta(rawArgs);\n args = extracted.args;\n rpcMeta = extracted.rpcMeta;\n }\n\n // For startNewTrace, always use withIsolationScope to ensure a fresh scope\n // Otherwise, use existing client's scope or isolation scope\n const currentClient = getClient();\n const sentryWithScope = startNewTrace ? withIsolationScope : currentClient ? withScope : withIsolationScope;\n\n const wrappedFunction = (scope: Scope): unknown | Promise<unknown> => {\n // In certain situations, the passed context can become undefined.\n // For example, for Astro while prerendering pages at build time.\n // see: https://github.com/getsentry/sentry-javascript/issues/13217\n const context: typeof wrapperOptions.context | undefined = wrapperOptions.context;\n\n const waitUntil = context?.waitUntil?.bind?.(context);\n const storage = context && 'originalStorage' in context ? context.originalStorage : undefined;\n\n let scopeClient = scope.getClient();\n // Check if client exists AND is still usable (transport not disposed)\n // This handles the case where a previous handler disposed the client\n // but the scope still holds a reference to it (e.g., alarm handlers in Durable Objects)\n // For startNewTrace, always create a fresh client\n if (startNewTrace || !scopeClient?.getTransport()) {\n const client = init({\n ...wrapperOptions.options,\n ctx: context as unknown as ExecutionContext | undefined,\n });\n scope.setClient(client);\n scopeClient = client;\n }\n\n const clientToDispose = scopeClient;\n const methodName = wrapperOptions.spanName || 'unknown';\n\n const teardown = async (): Promise<void> => {\n if (startNewTrace && storage) {\n await storeSpanContext(storage, methodName);\n }\n await flushAndDispose(clientToDispose);\n };\n\n if (!wrapperOptions.spanName) {\n try {\n if (callback) {\n callback(...args);\n }\n\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(\n (res: unknown) => {\n waitUntil?.(teardown());\n return res;\n },\n (e: unknown) => {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n },\n );\n } else {\n waitUntil?.(teardown());\n return result;\n }\n } catch (e) {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n }\n }\n\n const attributes = wrapperOptions.spanOp\n ? {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.durable_object',\n }\n : {};\n\n const executeSpan = (): unknown => {\n return startSpan({ name: methodName, attributes }, span => {\n // When linking to previous trace, fetch the stored context and add links asynchronously\n // This avoids blocking the response while fetching from storage\n if (startNewTrace && storage) {\n waitUntil?.(\n getStoredSpanContext(storage, methodName).then(storedContext => {\n if (storedContext) {\n span.addLinks(buildSpanLinks(storedContext));\n // TODO: Remove this once EAP can store span links. We currently only set this attribute so that we\n // can obtain the previous trace information from the EAP store. Long-term, EAP will handle\n // span links and then we should remove this again. Also throwing in a TODO(v11), to remind us\n // to check this at v11 time :)\n const sampledFlag = storedContext.sampled ? '1' : '0';\n span.setAttribute(\n 'sentry.previous_trace',\n `${storedContext.traceId}-${storedContext.spanId}-${sampledFlag}`,\n );\n }\n }),\n );\n }\n\n try {\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(\n (res: unknown) => {\n waitUntil?.(teardown());\n return res;\n },\n (e: unknown) => {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n },\n );\n } else {\n waitUntil?.(teardown());\n return result;\n }\n } catch (e) {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n }\n });\n };\n\n if (rpcMeta) {\n return continueTrace(\n { sentryTrace: rpcMeta['sentry-trace'] || '', baggage: rpcMeta.baggage || '' },\n executeSpan,\n );\n }\n\n if (startNewTrace) {\n return startNewTraceCore(() => executeSpan());\n }\n\n return executeSpan();\n };\n\n return sentryWithScope(wrappedFunction);\n },\n }),\n noMark,\n );\n}\n"],"names":["startNewTrace","startNewTraceCore"],"mappings":";;;;;;;AAsBA;;AA2BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB;AACpC,EAAE,cAAc;AAChB,EAAE,OAAO;AACT,EAAE,QAAQ;AACV,EAAE,MAAM;AACR,EAAK;AACL,EAAE,OAAO,kBAAkB;AAC3B,IAAI,OAAO;AACX,IAAI,QAAA;AACJ,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE;AAC1B,QAAQ,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAiB;AACvD,UAAU,MAAM,iBAAEA,eAAA,EAAc,GAAI,cAAc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CAAA,eAAA,CAAA;AACA,QAAA,CAAA;AACA,OAAA,CAAA;AACA,IAAA,MAAA;AACA,GAAA;AACA;;;;"}
1
+ {"version":3,"file":"wrapMethodWithSentry.js","sources":["../../src/wrapMethodWithSentry.ts"],"sourcesContent":["import type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport type { SerializedTraceData } from '@sentry/core';\nimport {\n captureException,\n continueTrace,\n getClient,\n isThenable,\n type Scope,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startNewTrace as startNewTraceCore,\n startSpan,\n withIsolationScope,\n withScope,\n} from '@sentry/core';\nimport type { CloudflareOptions } from './client';\nimport { flushAndDispose } from './flush';\nimport { ensureInstrumented } from './instrument';\nimport { init } from './sdk';\nimport { extractRpcMeta } from './utils/rpcMeta';\nimport { buildSpanLinks, getStoredSpanContext, storeSpanContext } from './utils/traceLinks';\n\n/** Extended DurableObjectState with originalStorage exposed by instrumentContext */\ninterface InstrumentedDurableObjectState extends DurableObjectState {\n originalStorage?: DurableObjectStorage;\n}\n\ntype MethodWrapperOptions = {\n spanName?: string;\n spanOp?: string;\n options: CloudflareOptions;\n context: ExecutionContext | InstrumentedDurableObjectState;\n /**\n * If true, starts a fresh trace instead of inheriting from a parent trace.\n * Useful for scheduled/independent invocations like alarms.\n *\n * If true, it also stores the current span context and links to the previous invocation's span.\n * Uses Durable Object storage to persist the link. The link is set asynchronously via `span.addLinks()`\n * in a `waitUntil` to avoid blocking.\n *\n * @default false\n */\n startNewTrace?: boolean;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UncheckedMethod = (...args: any[]) => any;\ntype OriginalMethod = UncheckedMethod;\n\n/**\n * Wraps a method with Sentry error tracking and optional tracing.\n * Supports starting new traces and linking to previous invocations via Durable Object storage.\n *\n * @param wrapperOptions - The options for the wrapper.\n * @param handler - The method to wrap.\n * @param callback - The callback to call.\n * @param noMark - Whether to mark the method as instrumented.\n * @returns The wrapped method.\n */\nexport function wrapMethodWithSentry<T extends OriginalMethod>(\n wrapperOptions: MethodWrapperOptions,\n handler: T,\n callback?: (...args: Parameters<T>) => void,\n noMark?: true,\n): T {\n return ensureInstrumented(\n handler,\n original =>\n new Proxy(original, {\n apply(target, thisArg, rawArgs: Parameters<T>) {\n const { startNewTrace } = wrapperOptions;\n\n // For RPC methods, extract Sentry trace context from the trailing argument.\n // The caller side (instrumentDurableObjectStub / JSRPC proxy) appends it;\n // we strip it here so the user's method never sees it.\n let args = rawArgs;\n let rpcMeta: SerializedTraceData | undefined;\n\n if (wrapperOptions.spanOp === 'rpc') {\n const extracted = extractRpcMeta(rawArgs);\n args = extracted.args;\n rpcMeta = extracted.rpcMeta;\n }\n\n // For startNewTrace, always use withIsolationScope to ensure a fresh scope\n // Otherwise, use existing client's scope or isolation scope\n const currentClient = getClient();\n const sentryWithScope = startNewTrace ? withIsolationScope : currentClient ? withScope : withIsolationScope;\n\n const wrappedFunction = (scope: Scope): unknown | Promise<unknown> => {\n // In certain situations, the passed context can become undefined.\n // For example, for Astro while prerendering pages at build time.\n // see: https://github.com/getsentry/sentry-javascript/issues/13217\n const context: typeof wrapperOptions.context | undefined = wrapperOptions.context;\n\n const waitUntil = context?.waitUntil?.bind?.(context);\n const storage = context && 'originalStorage' in context ? context.originalStorage : undefined;\n\n let scopeClient = scope.getClient();\n // Check if client exists AND is still usable (transport not disposed)\n // This handles the case where a previous handler disposed the client\n // but the scope still holds a reference to it (e.g., alarm handlers in Durable Objects)\n // For startNewTrace, always create a fresh client\n if (startNewTrace || !scopeClient?.getTransport()) {\n const client = init({\n ...wrapperOptions.options,\n ctx: context as unknown as ExecutionContext | undefined,\n });\n scope.setClient(client);\n scopeClient = client;\n }\n\n const clientToDispose = scopeClient;\n const methodName = wrapperOptions.spanName || 'unknown';\n\n const teardown = async (): Promise<void> => {\n if (startNewTrace && storage) {\n await storeSpanContext(storage, methodName);\n }\n await flushAndDispose(clientToDispose);\n };\n\n if (!wrapperOptions.spanName) {\n try {\n if (callback) {\n callback(...args);\n }\n\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(\n (res: unknown) => {\n waitUntil?.(teardown());\n return res;\n },\n (e: unknown) => {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n },\n );\n } else {\n waitUntil?.(teardown());\n return result;\n }\n } catch (e) {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n }\n }\n\n const attributes = wrapperOptions.spanOp\n ? {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.durable_object',\n }\n : {};\n\n const executeSpan = (): unknown => {\n return startSpan({ name: methodName, attributes }, span => {\n // When linking to previous trace, fetch the stored context and add links asynchronously\n // This avoids blocking the response while fetching from storage\n if (startNewTrace && storage) {\n waitUntil?.(\n getStoredSpanContext(storage, methodName).then(storedContext => {\n if (storedContext) {\n span.addLinks(buildSpanLinks(storedContext));\n // TODO: Remove this once EAP can store span links. We currently only set this attribute so that we\n // can obtain the previous trace information from the EAP store. Long-term, EAP will handle\n // span links and then we should remove this again. Also throwing in a TODO(v11), to remind us\n // to check this at v11 time :)\n const sampledFlag = storedContext.sampled ? '1' : '0';\n span.setAttribute(\n 'sentry.previous_trace',\n `${storedContext.traceId}-${storedContext.spanId}-${sampledFlag}`,\n );\n }\n }),\n );\n }\n\n try {\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(\n (res: unknown) => {\n waitUntil?.(teardown());\n return res;\n },\n (e: unknown) => {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n },\n );\n } else {\n waitUntil?.(teardown());\n return result;\n }\n } catch (e) {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n }\n });\n };\n\n if (rpcMeta) {\n return continueTrace(\n { sentryTrace: rpcMeta['sentry-trace'] || '', baggage: rpcMeta.baggage || '' },\n executeSpan,\n );\n }\n\n if (startNewTrace) {\n return startNewTraceCore(() => executeSpan());\n }\n\n return executeSpan();\n };\n\n return sentryWithScope(wrappedFunction);\n },\n }),\n noMark,\n );\n}\n"],"names":["startNewTrace","startNewTraceCore"],"mappings":";;;;;;;AA2DO,SAAS,oBAAA,CACd,cAAA,EACA,OAAA,EACA,QAAA,EACA,MAAA,EACG;AACH,EAAA,OAAO,kBAAA;AAAA,IACL,OAAA;AAAA,IACA,CAAA,QAAA,KACE,IAAI,KAAA,CAAM,QAAA,EAAU;AAAA,MAClB,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,OAAA,EAAwB;AAC7C,QAAA,MAAM,iBAAEA,iBAAc,GAAI,cAAA;AAK1B,QAAA,IAAI,IAAA,GAAO,OAAA;AACX,QAAA,IAAI,OAAA;AAEJ,QAAA,IAAI,cAAA,CAAe,WAAW,KAAA,EAAO;AACnC,UAAA,MAAM,SAAA,GAAY,eAAe,OAAO,CAAA;AACxC,UAAA,IAAA,GAAO,SAAA,CAAU,IAAA;AACjB,UAAA,OAAA,GAAU,SAAA,CAAU,OAAA;AAAA,QACtB;AAIA,QAAA,MAAM,gBAAgB,SAAA,EAAU;AAChC,QAAA,MAAM,eAAA,GAAkBA,eAAA,GAAgB,kBAAA,GAAqB,aAAA,GAAgB,SAAA,GAAY,kBAAA;AAEzF,QAAA,MAAM,eAAA,GAAkB,CAAC,KAAA,KAA6C;AAIpE,UAAA,MAAM,UAAqD,cAAA,CAAe,OAAA;AAE1E,UAAA,MAAM,SAAA,GAAY,OAAA,EAAS,SAAA,EAAW,IAAA,GAAO,OAAO,CAAA;AACpD,UAAA,MA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CAAC;IAEvB;;;;;;;;;;OAUG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IAEpC;;;;;;;;;;;OAWG;IACH,0BAA0B,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAC;CACjD;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAkB,SAAQ,OAAO,CAAC,0BAA0B,CAAC,EAAE,qBAAqB;IACnG,GAAG,CAAC,EAAE,gBAAgB,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,aAAa,CAAC,0BAA0B,CAAC,EAAE,qBAAqB;IAC/G,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;CAC9C"}
@@ -4,6 +4,21 @@ type FlushLock = {
4
4
  readonly ready: Promise<void>;
5
5
  readonly finalize: () => Promise<void>;
6
6
  };
7
+ /**
8
+ * Returns the original (un-instrumented) waitUntil function for a context.
9
+ * This should be used when calling waitUntil with flushAndDispose to avoid deadlock.
10
+ *
11
+ * The flush lock mechanism wraps context.waitUntil to track pending tasks.
12
+ * If we call waitUntil(flushAndDispose(client)) through the instrumented version,
13
+ * it creates a deadlock because:
14
+ * 1. The instrumented waitUntil acquires the flush lock
15
+ * 2. flushAndDispose calls client.flush() which waits for the lock to be released
16
+ * 3. The lock won't be released until the waitUntil promise completes
17
+ * 4. The waitUntil promise won't complete until flush() returns
18
+ *
19
+ * By using the original waitUntil for flush operations, we bypass this issue.
20
+ */
21
+ export declare function getOriginalWaitUntil(context: ExecutionContext): ExecutionContext['waitUntil'] | undefined;
7
22
  /**
8
23
  * Enhances the given execution context by wrapping its `waitUntil` method with a proxy
9
24
  * to monitor pending tasks, and provides a flusher function to ensure all tasks
@@ -1 +1 @@
1
- {"version":3,"file":"flush.d.ts","sourceRoot":"","sources":["../../src/flush.ts"],"names":[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entFetch.d.ts","sourceRoot":"","sources":["../../../../src/instrumentations/worker/instrumentFetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,GAAG,IAAI,aAAa,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAOtD;;GAEG;AAEH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EACrF,OAAO,EAAE,CAAC,EACV,eAAe,EAAE,CAAC,GAAG,EAAE,OAAO,aAAa,KAAK,iBAAiB,GAAG,SAAS,GAC5E,IAAI,CAoBN;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,CAAC,SAAS,gBAAgB,EACxE,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,gBAAgB,GACxB,IAAI,CAaN"}
1
+ {"version":3,"file":"instrumentFetch.d.ts","sourceRoot":"","sources":["../../../../src/instrumentations/worker/instrumentFetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,GAAG,IAAI,aAAa,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAOtD;;GAEG;AAEH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EACrF,OAAO,EAAE,CAAC,EACV,eAAe,EAAE,CAAC,GAAG,EAAE,OAAO,aAAa,KAAK,iBAAiB,GAAG,SAAS,GAC5E,IAAI,CAyBN;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,CAAC,SAAS,gBAAgB,EACxE,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,gBAAgB,GACxB,IAAI,CAiBN"}
@@ -25,6 +25,9 @@ declare const _honoIntegration: (options?: Partial<Options>) => {
25
25
  *
26
26
  * The integration is enabled by default.
27
27
  *
28
+ * @deprecated Use the `@sentry/hono` package instead. The `sentry()` middleware from `@sentry/hono/cloudflare`
29
+ * handles error capturing automatically without needing this integration.
30
+ *
28
31
  * @example
29
32
  * integrations: [
30
33
  * honoIntegration({
@@ -1 +1 @@
1
- {"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../../../src/integrations/hono.ts"],"names":[],"mappings":"AAeA,UAAU,SAAU,SAAQ,KAAK;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAGD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACxC;AAED,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,iBAAiB,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC;CAC3D;AAED,qCAAqC;AACrC,wBAAgB,kBAAkB,IAAI,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAAG,SAAS,CAEpF;AAYD,QAAA,MAAM,gBAAgB,aAAc,OAAO,CAAC,OAAO,CAAC;;6BAIvB,SAAS,WAAW,WAAW,GAAG,IAAI;CA2BzC,CAAC;AAE3B;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,gFAAsC,CAAC"}
1
+ {"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../../../src/integrations/hono.ts"],"names":[],"mappings":"AAeA,UAAU,SAAU,SAAQ,KAAK;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAGD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACxC;AAED,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,iBAAiB,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC;CAC3D;AAED,qCAAqC;AACrC,wBAAgB,kBAAkB,IAAI,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAAG,SAAS,CAEpF;AAYD,QAAA,MAAM,gBAAgB,aAAc,OAAO,CAAC,OAAO,CAAC;;6BAIvB,SAAS,WAAW,WAAW,GAAG,IAAI;CA2BzC,CAAC;AAE3B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,gFAAsC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"pages-plugin.d.ts","sourceRoot":"","sources":["../../src/pages-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,GAAG,OAAO,EAEb,MAAM,SAAS,MAAM,GAAG,GAAG,EAC3B,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAG9D,YAAY,GAAG,GAAG,EAElB,gBAAgB,EACZ,iBAAiB,GACjB,CAAC,CAAC,OAAO,EAAE,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,KAAK,iBAAiB,CAAC,GACxF,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAQtD"}
1
+ {"version":3,"file":"pages-plugin.d.ts","sourceRoot":"","sources":["../../src/pages-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,GAAG,OAAO,EAEb,MAAM,SAAS,MAAM,GAAG,GAAG,EAC3B,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAG9D,YAAY,GAAG,GAAG,EAElB,gBAAgB,EACZ,iBAAiB,GACjB,CAAC,CAAC,OAAO,EAAE,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,KAAK,iBAAiB,CAAC,GACxF,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAYtD"}
@@ -1 +1 @@
1
- {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAe7G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAMlD,UAAU,4BAA4B;IACpC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,2BAA2B,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IACxF,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACtC;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,4BAA4B,EAC5C,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAC5D,OAAO,CAAC,QAAQ,CAAC,CAgJnB"}
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAe7G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAMlD,UAAU,4BAA4B;IACpC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,2BAA2B,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IACxF,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACtC;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,4BAA4B,EAC5C,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAC5D,OAAO,CAAC,QAAQ,CAAC,CAqJnB"}
@@ -4,6 +4,21 @@ type FlushLock = {
4
4
  readonly ready: Promise<void>;
5
5
  readonly finalize: () => Promise<void>;
6
6
  };
7
+ /**
8
+ * Returns the original (un-instrumented) waitUntil function for a context.
9
+ * This should be used when calling waitUntil with flushAndDispose to avoid deadlock.
10
+ *
11
+ * The flush lock mechanism wraps context.waitUntil to track pending tasks.
12
+ * If we call waitUntil(flushAndDispose(client)) through the instrumented version,
13
+ * it creates a deadlock because:
14
+ * 1. The instrumented waitUntil acquires the flush lock
15
+ * 2. flushAndDispose calls client.flush() which waits for the lock to be released
16
+ * 3. The lock won't be released until the waitUntil promise completes
17
+ * 4. The waitUntil promise won't complete until flush() returns
18
+ *
19
+ * By using the original waitUntil for flush operations, we bypass this issue.
20
+ */
21
+ export declare function getOriginalWaitUntil(context: ExecutionContext): ExecutionContext['waitUntil'] | undefined;
7
22
  /**
8
23
  * Enhances the given execution context by wrapping its `waitUntil` method with a proxy
9
24
  * to monitor pending tasks, and provides a flusher function to ensure all tasks
@@ -25,6 +25,9 @@ declare const _honoIntegration: (options?: Partial<Options>) => {
25
25
  *
26
26
  * The integration is enabled by default.
27
27
  *
28
+ * @deprecated Use the `@sentry/hono` package instead. The `sentry()` middleware from `@sentry/hono/cloudflare`
29
+ * handles error capturing automatically without needing this integration.
30
+ *
28
31
  * @example
29
32
  * integrations: [
30
33
  * honoIntegration({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/cloudflare",
3
- "version": "10.53.1",
3
+ "version": "10.55.0",
4
4
  "description": "Official Sentry SDK for Cloudflare Workers and Pages",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/cloudflare",
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@opentelemetry/api": "^1.9.1",
53
- "@sentry/core": "10.53.1"
53
+ "@sentry/core": "10.55.0"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@cloudflare/workers-types": "^4.x"