effect 4.1.5 → 4.1.6

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 (309) hide show
  1. package/ai-docs/package.json +2 -2
  2. package/dist/Channel.d.ts +104 -7
  3. package/dist/Channel.d.ts.map +1 -1
  4. package/dist/Channel.js +73 -4
  5. package/dist/Channel.js.map +1 -1
  6. package/dist/Codegen.d.ts +7 -2
  7. package/dist/Codegen.d.ts.map +1 -1
  8. package/dist/Codegen.js +7 -2
  9. package/dist/Codegen.js.map +1 -1
  10. package/dist/Effect.d.ts +139 -18
  11. package/dist/Effect.d.ts.map +1 -1
  12. package/dist/Effect.js +10 -2
  13. package/dist/Effect.js.map +1 -1
  14. package/dist/Equal.d.ts +4 -4
  15. package/dist/Equal.d.ts.map +1 -1
  16. package/dist/Equal.js +78 -65
  17. package/dist/Equal.js.map +1 -1
  18. package/dist/Hash.d.ts.map +1 -1
  19. package/dist/Hash.js +24 -17
  20. package/dist/Hash.js.map +1 -1
  21. package/dist/LayerRef.d.ts +1 -1
  22. package/dist/LayerRef.d.ts.map +1 -1
  23. package/dist/LayerRef.js +3 -3
  24. package/dist/LayerRef.js.map +1 -1
  25. package/dist/Logger.d.ts +37 -13
  26. package/dist/Logger.d.ts.map +1 -1
  27. package/dist/Logger.js +39 -10
  28. package/dist/Logger.js.map +1 -1
  29. package/dist/Match.d.ts +23 -23
  30. package/dist/Match.d.ts.map +1 -1
  31. package/dist/Match.js.map +1 -1
  32. package/dist/Order.js +1 -1
  33. package/dist/Order.js.map +1 -1
  34. package/dist/Schema.d.ts +41 -0
  35. package/dist/Schema.d.ts.map +1 -1
  36. package/dist/Schema.js +51 -390
  37. package/dist/Schema.js.map +1 -1
  38. package/dist/SchemaAST.d.ts.map +1 -1
  39. package/dist/SchemaAST.js +0 -3
  40. package/dist/SchemaAST.js.map +1 -1
  41. package/dist/ScopedCache.d.ts.map +1 -1
  42. package/dist/ScopedCache.js +6 -4
  43. package/dist/ScopedCache.js.map +1 -1
  44. package/dist/Stream.d.ts +128 -5
  45. package/dist/Stream.d.ts.map +1 -1
  46. package/dist/Stream.js +124 -29
  47. package/dist/Stream.js.map +1 -1
  48. package/dist/String.js +1 -1
  49. package/dist/String.js.map +1 -1
  50. package/dist/Tracer.d.ts +10 -0
  51. package/dist/Tracer.d.ts.map +1 -1
  52. package/dist/Tracer.js +2 -0
  53. package/dist/Tracer.js.map +1 -1
  54. package/dist/ai/McpSchema.d.ts +88 -88
  55. package/dist/ai/McpSchema.d.ts.map +1 -1
  56. package/dist/ai/McpServer.d.ts +152 -2
  57. package/dist/ai/McpServer.d.ts.map +1 -1
  58. package/dist/ai/McpServer.js +8 -2
  59. package/dist/ai/McpServer.js.map +1 -1
  60. package/dist/ai/Prompt.d.ts +3 -1
  61. package/dist/ai/Prompt.d.ts.map +1 -1
  62. package/dist/ai/Prompt.js +17 -3
  63. package/dist/ai/Prompt.js.map +1 -1
  64. package/dist/ai/Skill.d.ts +172 -0
  65. package/dist/ai/Skill.d.ts.map +1 -0
  66. package/dist/ai/Skill.js +209 -0
  67. package/dist/ai/Skill.js.map +1 -0
  68. package/dist/ai/index.d.ts +5 -0
  69. package/dist/ai/index.d.ts.map +1 -1
  70. package/dist/ai/index.js +5 -0
  71. package/dist/ai/index.js.map +1 -1
  72. package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  73. package/dist/cluster/ClusterWorkflowEngine.js +155 -83
  74. package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
  75. package/dist/cluster/MessageStorage.d.ts +56 -0
  76. package/dist/cluster/MessageStorage.d.ts.map +1 -1
  77. package/dist/cluster/MessageStorage.js +18 -2
  78. package/dist/cluster/MessageStorage.js.map +1 -1
  79. package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
  80. package/dist/cluster/SqlMessageStorage.js +45 -22
  81. package/dist/cluster/SqlMessageStorage.js.map +1 -1
  82. package/dist/cluster/internal/entityActivation.js +2 -0
  83. package/dist/cluster/internal/entityActivation.js.map +1 -1
  84. package/dist/cluster/internal/entityManager.js +8 -5
  85. package/dist/cluster/internal/entityManager.js.map +1 -1
  86. package/dist/encoding/Base64.js +5 -1
  87. package/dist/encoding/Base64.js.map +1 -1
  88. package/dist/encoding/Base64Url.d.ts.map +1 -1
  89. package/dist/encoding/Base64Url.js +6 -1
  90. package/dist/encoding/Base64Url.js.map +1 -1
  91. package/dist/encoding/Xml.d.ts +38 -9
  92. package/dist/encoding/Xml.d.ts.map +1 -1
  93. package/dist/encoding/Xml.js +63 -31
  94. package/dist/encoding/Xml.js.map +1 -1
  95. package/dist/http/FetchHttpClient.d.ts +2 -1
  96. package/dist/http/FetchHttpClient.d.ts.map +1 -1
  97. package/dist/http/FetchHttpClient.js +14 -10
  98. package/dist/http/FetchHttpClient.js.map +1 -1
  99. package/dist/http/Headers.d.ts +201 -3
  100. package/dist/http/Headers.d.ts.map +1 -1
  101. package/dist/http/Headers.js +205 -3
  102. package/dist/http/Headers.js.map +1 -1
  103. package/dist/http/HttpClient.d.ts.map +1 -1
  104. package/dist/http/HttpClient.js +11 -7
  105. package/dist/http/HttpClient.js.map +1 -1
  106. package/dist/http/HttpClientError.d.ts +1 -0
  107. package/dist/http/HttpClientError.d.ts.map +1 -1
  108. package/dist/http/HttpClientError.js +32 -9
  109. package/dist/http/HttpClientError.js.map +1 -1
  110. package/dist/http/HttpClientRequest.d.ts +46 -0
  111. package/dist/http/HttpClientRequest.d.ts.map +1 -1
  112. package/dist/http/HttpClientRequest.js +15 -0
  113. package/dist/http/HttpClientRequest.js.map +1 -1
  114. package/dist/http/HttpClientResponse.d.ts +132 -0
  115. package/dist/http/HttpClientResponse.d.ts.map +1 -1
  116. package/dist/http/HttpClientResponse.js +83 -0
  117. package/dist/http/HttpClientResponse.js.map +1 -1
  118. package/dist/http/HttpMiddleware.js +1 -1
  119. package/dist/http/HttpMiddleware.js.map +1 -1
  120. package/dist/http/HttpServerResponse.d.ts +118 -0
  121. package/dist/http/HttpServerResponse.d.ts.map +1 -1
  122. package/dist/http/HttpServerResponse.js +43 -0
  123. package/dist/http/HttpServerResponse.js.map +1 -1
  124. package/dist/http/Multipart.d.ts.map +1 -1
  125. package/dist/http/Multipart.js +0 -5
  126. package/dist/http/Multipart.js.map +1 -1
  127. package/dist/http/MultipartParser/internal/contentType.d.ts +6 -0
  128. package/dist/http/MultipartParser/internal/contentType.d.ts.map +1 -1
  129. package/dist/http/MultipartParser/internal/contentType.js +1 -1
  130. package/dist/http/MultipartParser/internal/contentType.js.map +1 -1
  131. package/dist/http/internal/clientPath.d.ts +2 -0
  132. package/dist/http/internal/clientPath.d.ts.map +1 -0
  133. package/dist/http/internal/clientPath.js +24 -0
  134. package/dist/http/internal/clientPath.js.map +1 -0
  135. package/dist/http/internal/redactedPath.js +2 -0
  136. package/dist/http/internal/redactedPath.js.map +1 -1
  137. package/dist/http/internal/tracing.js +5 -3
  138. package/dist/http/internal/tracing.js.map +1 -1
  139. package/dist/http-api/HttpApi.d.ts +2 -2
  140. package/dist/http-api/HttpApi.d.ts.map +1 -1
  141. package/dist/http-api/HttpApi.js +30 -7
  142. package/dist/http-api/HttpApi.js.map +1 -1
  143. package/dist/http-api/HttpApiBuilder.d.ts.map +1 -1
  144. package/dist/http-api/HttpApiBuilder.js +5 -2
  145. package/dist/http-api/HttpApiBuilder.js.map +1 -1
  146. package/dist/http-api/HttpApiClient.d.ts.map +1 -1
  147. package/dist/http-api/HttpApiClient.js +23 -6
  148. package/dist/http-api/HttpApiClient.js.map +1 -1
  149. package/dist/http-api/internal/redactedKeys.d.ts +2 -0
  150. package/dist/http-api/internal/redactedKeys.d.ts.map +1 -0
  151. package/dist/http-api/internal/redactedKeys.js +37 -0
  152. package/dist/http-api/internal/redactedKeys.js.map +1 -0
  153. package/dist/internal/base64.js +34 -2
  154. package/dist/internal/base64.js.map +1 -1
  155. package/dist/internal/dateTime.js +35 -17
  156. package/dist/internal/dateTime.js.map +1 -1
  157. package/dist/internal/effect.js +9 -1
  158. package/dist/internal/effect.js.map +1 -1
  159. package/dist/internal/equal.js +14 -13
  160. package/dist/internal/equal.js.map +1 -1
  161. package/dist/internal/hash.js +4 -1
  162. package/dist/internal/hash.js.map +1 -1
  163. package/dist/internal/matcher.js +17 -17
  164. package/dist/internal/matcher.js.map +1 -1
  165. package/dist/internal/schema/schemaCodegen.js +3 -2
  166. package/dist/internal/schema/schemaCodegen.js.map +1 -1
  167. package/dist/internal/schema/schemaCodegenBuiltIns.d.ts +2 -0
  168. package/dist/internal/schema/schemaCodegenBuiltIns.d.ts.map +1 -0
  169. package/dist/internal/schema/schemaCodegenBuiltIns.js +425 -0
  170. package/dist/internal/schema/schemaCodegenBuiltIns.js.map +1 -0
  171. package/dist/internal/schema/toEquivalence.js +3 -4
  172. package/dist/internal/schema/toEquivalence.js.map +1 -1
  173. package/dist/internal/version.js +1 -1
  174. package/dist/jose/JoseError.d.ts +51 -1
  175. package/dist/jose/JoseError.d.ts.map +1 -1
  176. package/dist/jose/JoseError.js +25 -18
  177. package/dist/jose/JoseError.js.map +1 -1
  178. package/dist/jose/internal/compact.js +10 -5
  179. package/dist/jose/internal/compact.js.map +1 -1
  180. package/dist/observability/Otlp.d.ts +19 -0
  181. package/dist/observability/Otlp.d.ts.map +1 -1
  182. package/dist/observability/Otlp.js +10 -0
  183. package/dist/observability/Otlp.js.map +1 -1
  184. package/dist/observability/OtlpExporter.d.ts +49 -13
  185. package/dist/observability/OtlpExporter.d.ts.map +1 -1
  186. package/dist/observability/OtlpExporter.js +135 -54
  187. package/dist/observability/OtlpExporter.js.map +1 -1
  188. package/dist/observability/OtlpLogger.d.ts +14 -0
  189. package/dist/observability/OtlpLogger.d.ts.map +1 -1
  190. package/dist/observability/OtlpLogger.js +10 -2
  191. package/dist/observability/OtlpLogger.js.map +1 -1
  192. package/dist/observability/OtlpMetrics.d.ts.map +1 -1
  193. package/dist/observability/OtlpMetrics.js +2 -0
  194. package/dist/observability/OtlpMetrics.js.map +1 -1
  195. package/dist/observability/OtlpTracer.d.ts +14 -0
  196. package/dist/observability/OtlpTracer.d.ts.map +1 -1
  197. package/dist/observability/OtlpTracer.js +10 -2
  198. package/dist/observability/OtlpTracer.js.map +1 -1
  199. package/dist/persistence/KeyValueStore.d.ts.map +1 -1
  200. package/dist/persistence/KeyValueStore.js +6 -4
  201. package/dist/persistence/KeyValueStore.js.map +1 -1
  202. package/dist/reactivity/Atom.d.ts.map +1 -1
  203. package/dist/reactivity/Atom.js +10 -9
  204. package/dist/reactivity/Atom.js.map +1 -1
  205. package/dist/rpc/RpcClient.d.ts.map +1 -1
  206. package/dist/rpc/RpcClient.js +32 -1
  207. package/dist/rpc/RpcClient.js.map +1 -1
  208. package/dist/rpc/RpcGroup.d.ts +1 -1
  209. package/dist/rpc/RpcGroup.d.ts.map +1 -1
  210. package/dist/rpc/RpcGroup.js +4 -0
  211. package/dist/rpc/RpcGroup.js.map +1 -1
  212. package/dist/sql/Migrator.d.ts.map +1 -1
  213. package/dist/sql/Migrator.js +2 -5
  214. package/dist/sql/Migrator.js.map +1 -1
  215. package/dist/sql/SqlClient.d.ts.map +1 -1
  216. package/dist/sql/SqlClient.js +5 -1
  217. package/dist/sql/SqlClient.js.map +1 -1
  218. package/dist/workflow/Activity.d.ts +18 -0
  219. package/dist/workflow/Activity.d.ts.map +1 -1
  220. package/dist/workflow/Activity.js +13 -4
  221. package/dist/workflow/Activity.js.map +1 -1
  222. package/dist/workflow/Workflow.d.ts +10 -9
  223. package/dist/workflow/Workflow.d.ts.map +1 -1
  224. package/dist/workflow/Workflow.js +33 -22
  225. package/dist/workflow/Workflow.js.map +1 -1
  226. package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
  227. package/dist/workflow/WorkflowEngine.js +26 -12
  228. package/dist/workflow/WorkflowEngine.js.map +1 -1
  229. package/dist/workflow/internal/retry.d.ts +2 -0
  230. package/dist/workflow/internal/retry.d.ts.map +1 -0
  231. package/dist/workflow/internal/retry.js +11 -0
  232. package/dist/workflow/internal/retry.js.map +1 -0
  233. package/dist/workflow/internal/scope.d.ts +2 -0
  234. package/dist/workflow/internal/scope.d.ts.map +1 -0
  235. package/dist/workflow/internal/scope.js +26 -0
  236. package/dist/workflow/internal/scope.js.map +1 -0
  237. package/package.json +3 -3
  238. package/src/Channel.ts +105 -8
  239. package/src/Codegen.ts +7 -2
  240. package/src/Effect.ts +224 -48
  241. package/src/Equal.ts +85 -79
  242. package/src/Hash.ts +30 -22
  243. package/src/LayerRef.ts +6 -4
  244. package/src/Logger.ts +68 -25
  245. package/src/Match.ts +78 -50
  246. package/src/Order.ts +1 -1
  247. package/src/Schema.ts +79 -296
  248. package/src/SchemaAST.ts +0 -1
  249. package/src/ScopedCache.ts +6 -4
  250. package/src/Stream.ts +167 -33
  251. package/src/String.ts +1 -1
  252. package/src/Tracer.ts +10 -0
  253. package/src/ai/McpServer.ts +161 -4
  254. package/src/ai/Prompt.ts +20 -3
  255. package/src/ai/Skill.ts +236 -0
  256. package/src/ai/index.ts +6 -0
  257. package/src/cluster/ClusterWorkflowEngine.ts +172 -96
  258. package/src/cluster/MessageStorage.ts +51 -2
  259. package/src/cluster/SqlMessageStorage.ts +81 -34
  260. package/src/cluster/internal/entityActivation.ts +6 -0
  261. package/src/cluster/internal/entityManager.ts +8 -4
  262. package/src/encoding/Base64.ts +5 -1
  263. package/src/encoding/Base64Url.ts +6 -1
  264. package/src/encoding/Xml.ts +96 -26
  265. package/src/http/FetchHttpClient.ts +8 -5
  266. package/src/http/Headers.ts +309 -3
  267. package/src/http/HttpClient.ts +19 -7
  268. package/src/http/HttpClientError.ts +42 -9
  269. package/src/http/HttpClientRequest.ts +51 -0
  270. package/src/http/HttpClientResponse.ts +156 -0
  271. package/src/http/HttpMiddleware.ts +1 -1
  272. package/src/http/HttpServerResponse.ts +126 -0
  273. package/src/http/Multipart.ts +0 -5
  274. package/src/http/MultipartParser/internal/contentType.ts +1 -1
  275. package/src/http/internal/clientPath.ts +39 -0
  276. package/src/http/internal/redactedPath.ts +4 -0
  277. package/src/http/internal/tracing.ts +6 -3
  278. package/src/http-api/HttpApi.ts +29 -8
  279. package/src/http-api/HttpApiBuilder.ts +7 -2
  280. package/src/http-api/HttpApiClient.ts +30 -7
  281. package/src/http-api/internal/redactedKeys.ts +40 -0
  282. package/src/internal/base64.ts +57 -2
  283. package/src/internal/dateTime.ts +43 -24
  284. package/src/internal/effect.ts +31 -102
  285. package/src/internal/equal.ts +37 -17
  286. package/src/internal/hash.ts +5 -1
  287. package/src/internal/matcher.ts +34 -113
  288. package/src/internal/schema/schemaCodegen.ts +5 -4
  289. package/src/internal/schema/schemaCodegenBuiltIns.ts +343 -0
  290. package/src/internal/schema/toEquivalence.ts +3 -5
  291. package/src/internal/version.ts +1 -1
  292. package/src/jose/JoseError.ts +34 -0
  293. package/src/jose/internal/compact.ts +14 -5
  294. package/src/observability/Otlp.ts +29 -0
  295. package/src/observability/OtlpExporter.ts +206 -75
  296. package/src/observability/OtlpLogger.ts +24 -2
  297. package/src/observability/OtlpMetrics.ts +2 -0
  298. package/src/observability/OtlpTracer.ts +24 -3
  299. package/src/persistence/KeyValueStore.ts +17 -14
  300. package/src/reactivity/Atom.ts +12 -18
  301. package/src/rpc/RpcClient.ts +26 -1
  302. package/src/rpc/RpcGroup.ts +4 -1
  303. package/src/sql/Migrator.ts +2 -11
  304. package/src/sql/SqlClient.ts +14 -8
  305. package/src/workflow/Activity.ts +28 -4
  306. package/src/workflow/Workflow.ts +68 -44
  307. package/src/workflow/WorkflowEngine.ts +38 -15
  308. package/src/workflow/internal/retry.ts +12 -0
  309. package/src/workflow/internal/scope.ts +36 -0
@@ -25,7 +25,7 @@ import * as Layer from "../Layer.ts"
25
25
  import * as Option from "../Option.ts"
26
26
  import type * as Scope from "../Scope.ts"
27
27
  import * as Tracer from "../Tracer.ts"
28
- import type { ExtractTag } from "../Types.ts"
28
+ import type { Concurrency, ExtractTag } from "../Types.ts"
29
29
  import * as Version from "../Version.ts"
30
30
  import * as OtlpEnv from "./internal/otlpEnv.ts"
31
31
  import * as Exporter from "./OtlpExporter.ts"
@@ -62,6 +62,11 @@ export const make: (
62
62
  readonly compression?: "gzip" | "none" | undefined
63
63
  readonly exportInterval?: Duration.Input | undefined
64
64
  readonly maxBatchSize?: number | undefined
65
+ /** Maximum pending queued spans (does not include in-flight batches). */
66
+ readonly maxQueueSize?: number | undefined
67
+ /** Maximum concurrent export requests, or `"unbounded"`. Defaults to `4`. */
68
+ readonly concurrency?: Concurrency | undefined
69
+ readonly onDrop?: ((count: number) => void) | undefined
65
70
  readonly context?: (<X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X) | undefined
66
71
  readonly shutdownTimeout?: Duration.Input | undefined
67
72
  }
@@ -84,6 +89,9 @@ export const make: (
84
89
  compression: options.compression,
85
90
  exportInterval: options.exportInterval ?? Duration.seconds(5),
86
91
  maxBatchSize: options.maxBatchSize ?? 1000,
92
+ maxQueueSize: options.maxQueueSize,
93
+ concurrency: options.concurrency,
94
+ onDrop: options.onDrop,
87
95
  body(spans) {
88
96
  const data: TraceData = {
89
97
  resourceSpans: [{
@@ -141,6 +149,11 @@ export const layer: (options: {
141
149
  readonly compression?: "gzip" | "none" | undefined
142
150
  readonly exportInterval?: Duration.Input | undefined
143
151
  readonly maxBatchSize?: number | undefined
152
+ /** Maximum pending queued spans (does not include in-flight batches). */
153
+ readonly maxQueueSize?: number | undefined
154
+ /** Maximum concurrent export requests, or `"unbounded"`. Defaults to `4`. */
155
+ readonly concurrency?: Concurrency | undefined
156
+ readonly onDrop?: ((count: number) => void) | undefined
144
157
  readonly context?: (<X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X) | undefined
145
158
  readonly shutdownTimeout?: Duration.Input | undefined
146
159
  }) => Layer.Layer<Exporter.Flusher, never, OtlpSerialization | HttpClient.HttpClient> = flow(
@@ -170,6 +183,9 @@ export const layerFromConfig = (options?: {
170
183
  readonly attributes?: Record<string, unknown>
171
184
  } | undefined
172
185
  readonly headers?: Headers.Input | undefined
186
+ /** Maximum concurrent export requests, or `"unbounded"`. Defaults to `4`. */
187
+ readonly concurrency?: Concurrency | undefined
188
+ readonly onDrop?: ((count: number) => void) | undefined
173
189
  readonly context?: (<X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X) | undefined
174
190
  }): Layer.Layer<Exporter.Flusher, never, HttpClient.HttpClient | OtlpSerialization> =>
175
191
  Effect.gen(function*() {
@@ -190,7 +206,8 @@ export const layerFromConfig = (options?: {
190
206
  tracesTimeout,
191
207
  exportTimeout,
192
208
  scheduleDelay,
193
- maxBatchSize
209
+ maxBatchSize,
210
+ maxQueueSize
194
211
  } = yield* Config.all({
195
212
  baseCompression: Config.option(Config.Literals(["gzip", "none"], "OTEL_EXPORTER_OTLP_COMPRESSION")),
196
213
  compression: Config.option(Config.Literals(["gzip", "none"], "OTEL_EXPORTER_OTLP_TRACES_COMPRESSION")),
@@ -202,7 +219,8 @@ export const layerFromConfig = (options?: {
202
219
  Config.map(Duration.millis)
203
220
  )
204
221
  ),
205
- maxBatchSize: Config.option(Config.Int("OTEL_BSP_MAX_EXPORT_BATCH_SIZE"))
222
+ maxBatchSize: Config.option(Config.Int("OTEL_BSP_MAX_EXPORT_BATCH_SIZE")),
223
+ maxQueueSize: Config.option(Config.Int("OTEL_BSP_MAX_QUEUE_SIZE"))
206
224
  })
207
225
 
208
226
  const shutdownTimeout = Option.firstSomeOf([tracesTimeout, baseTimeout, exportTimeout]).pipe(
@@ -216,6 +234,9 @@ export const layerFromConfig = (options?: {
216
234
  compression: Option.getOrElse(Option.firstSomeOf([compression, baseCompression]), () => "none" as const),
217
235
  exportInterval: Option.getOrUndefined(scheduleDelay),
218
236
  maxBatchSize: Option.getOrUndefined(maxBatchSize),
237
+ maxQueueSize: Option.getOrUndefined(maxQueueSize),
238
+ concurrency: options?.concurrency,
239
+ onDrop: options?.onDrop,
219
240
  context: options?.context,
220
241
  shutdownTimeout: Option.getOrUndefined(shutdownTimeout)
221
242
  })
@@ -432,6 +432,8 @@ export const layerMemory: Layer.Layer<KeyValueStore> = Layer.sync(KeyValueStore)
432
432
  })
433
433
  })
434
434
 
435
+ const utf8Decoder = new TextDecoder("utf-8", { ignoreBOM: true })
436
+
435
437
  /**
436
438
  * Provides a `KeyValueStore` backed by files in the specified directory.
437
439
  *
@@ -476,18 +478,20 @@ export const layerFileSystem = (
476
478
  return make({
477
479
  get: (key: string) =>
478
480
  withKeyPath("get", key, (path) =>
479
- Effect.catchTag(
480
- fs.readFileString(path),
481
- "PlatformError",
482
- (cause) =>
483
- cause.reason._tag === "NotFound" ? Effect.undefined : Effect.fail(
484
- new KeyValueStoreError({
485
- method: "get",
486
- key,
487
- message: `Unable to get item with key ${key}`,
488
- cause
489
- })
490
- )
481
+ fs.readFile(path).pipe(
482
+ Effect.map((bytes) => utf8Decoder.decode(bytes)),
483
+ Effect.catchTag(
484
+ "PlatformError",
485
+ (cause) =>
486
+ cause.reason._tag === "NotFound" ? Effect.undefined : Effect.fail(
487
+ new KeyValueStoreError({
488
+ method: "get",
489
+ key,
490
+ message: `Unable to get item with key ${key}`,
491
+ cause
492
+ })
493
+ )
494
+ )
491
495
  )),
492
496
  getUint8Array: (key: string) =>
493
497
  withKeyPath("getUint8Array", key, (path) =>
@@ -735,7 +739,6 @@ export const layerSql = (
735
739
  })
736
740
 
737
741
  const encoder = new TextEncoder()
738
- const decoder = new TextDecoder()
739
742
  const ValueTypeString = 0
740
743
  const ValueTypeUint8Array = 1
741
744
 
@@ -762,7 +765,7 @@ export const layerSql = (
762
765
  const row = rows[0]
763
766
  switch (row.value_type) {
764
767
  case ValueTypeString:
765
- return Effect.succeed(decoder.decode(row.value))
768
+ return Effect.succeed(utf8Decoder.decode(row.value))
766
769
  case ValueTypeUint8Array:
767
770
  return Effect.succeed(Base64.encode(row.value))
768
771
  default:
@@ -20,7 +20,7 @@ import * as Effect from "../Effect.ts"
20
20
  import * as Exit from "../Exit.ts"
21
21
  import * as Fiber from "../Fiber.ts"
22
22
  import type { LazyArg } from "../Function.ts"
23
- import { constant, constTrue, constVoid, dual, pipe } from "../Function.ts"
23
+ import { constant, constTrue, constVoid, dual } from "../Function.ts"
24
24
  import type * as Inspectable from "../Inspectable.ts"
25
25
  import { PipeInspectableProto } from "../internal/core.ts"
26
26
  import { getStackTraceLimit } from "../internal/stackTraceLimit.ts"
@@ -1016,12 +1016,14 @@ function makeStream<A, E>(
1016
1016
  }
1017
1017
  services = Context.add(services, AtomRegistry, ctx.registry)
1018
1018
 
1019
+ let emitted = false
1019
1020
  const run = Effect.scopedWith((scope) =>
1020
1021
  Effect.flatMap(Channel.toPullScoped(stream.channel, scope), (pull) =>
1021
1022
  Effect.whileLoop({
1022
1023
  while: constTrue,
1023
1024
  body: () => pull,
1024
1025
  step(arr) {
1026
+ emitted = true
1025
1027
  ctx.setSelf(AsyncResult.success(Arr.lastNonEmpty(arr), {
1026
1028
  waiting: true
1027
1029
  }))
@@ -1029,24 +1031,16 @@ function makeStream<A, E>(
1029
1031
  }))
1030
1032
  ).pipe(
1031
1033
  Effect.catchCause((cause) => {
1034
+ const current = ctx.self<AsyncResult.AsyncResult<A, E | Cause.NoSuchElementError>>()
1032
1035
  if (Pull.isDoneCause(cause)) {
1033
- pipe(
1034
- ctx.self<AsyncResult.AsyncResult<A, E | Cause.NoSuchElementError>>(),
1035
- Option.flatMap(AsyncResult.value),
1036
- Option.match({
1037
- onNone: () =>
1038
- ctx.setSelf(
1039
- AsyncResult.failWithPrevious(new Cause.NoSuchElementError(), {
1040
- previous: ctx.self<AsyncResult.AsyncResult<A, E | Cause.NoSuchElementError>>()
1041
- })
1042
- ),
1043
- onSome: (a) => ctx.setSelf(AsyncResult.success(a))
1044
- })
1036
+ const value = emitted ? Option.flatMap(current, AsyncResult.value) : Option.none()
1037
+ ctx.setSelf(
1038
+ Option.isSome(value)
1039
+ ? AsyncResult.success(value.value)
1040
+ : AsyncResult.failWithPrevious(new Cause.NoSuchElementError(), { previous: current })
1045
1041
  )
1046
1042
  } else {
1047
- ctx.setSelf(AsyncResult.failureWithPrevious(cause as Cause.Cause<E>, {
1048
- previous: ctx.self<AsyncResult.AsyncResult<A, E | Cause.NoSuchElementError>>()
1049
- }))
1043
+ ctx.setSelf(AsyncResult.failureWithPrevious(cause as Cause.Cause<E>, { previous: current }))
1050
1044
  }
1051
1045
  return Effect.void
1052
1046
  })
@@ -1168,9 +1162,9 @@ const makeSubRef = (
1168
1162
  function write(ctx: WriteContext<SubscriptionRef.SubscriptionRef<any>>, value: any) {
1169
1163
  const ref = ctx.get(refAtom)
1170
1164
  if (SubscriptionRef.isSubscriptionRef(ref)) {
1171
- Effect.runSync(SubscriptionRef.set(ref, value))
1165
+ Effect.runFork(SubscriptionRef.set(ref, value))
1172
1166
  } else if (AsyncResult.isSuccess(ref)) {
1173
- Effect.runSync(SubscriptionRef.set(ref.value, value))
1167
+ Effect.runFork(SubscriptionRef.set(ref.value, value))
1174
1168
  }
1175
1169
  }
1176
1170
  return writable((get) => {
@@ -1010,6 +1010,31 @@ const makeProtocolHttpUnbatched = (client: HttpClient.HttpClient) =>
1010
1010
  }
1011
1011
  }))
1012
1012
 
1013
+ const withBatchSpan = <A, E, R>(effect: Effect.Effect<A, E, R>, requests: ReadonlyArray<RequestEncoded>) => {
1014
+ const links: Array<Tracer.SpanLink> = []
1015
+ const seen = new Set<string>()
1016
+ let sampled = false
1017
+ for (const request of requests) {
1018
+ if (request.traceId === undefined || request.spanId === undefined || seen.has(request.spanId)) continue
1019
+ seen.add(request.spanId)
1020
+ const span = Tracer.externalSpan({ traceId: request.traceId, spanId: request.spanId, sampled: request.sampled })
1021
+ sampled ||= span.sampled
1022
+ links.push({ span, attributes: {} })
1023
+ }
1024
+ if (links.length === 0) return effect
1025
+ return Effect.withSpan(effect, "RpcClient.batch", {
1026
+ root: true,
1027
+ sampled,
1028
+ links,
1029
+ attributes: { batchSize: requests.length },
1030
+ captureStackTrace: false
1031
+ }).pipe(
1032
+ // Do not let the opener's tracing settings suppress tracing for other callers.
1033
+ Effect.provideService(Tracer.DisablePropagation, false),
1034
+ Effect.withTracerEnabled(true)
1035
+ )
1036
+ }
1037
+
1013
1038
  const makeProtocolHttpBatched = Effect.fnUntraced(function*(client: HttpClient.HttpClient, options: {
1014
1039
  readonly window: Duration.Input
1015
1040
  readonly maxSize?: number | undefined
@@ -1047,7 +1072,7 @@ const makeProtocolHttpBatched = Effect.fnUntraced(function*(client: HttpClient.H
1047
1072
  Effect.raceFirst(Effect.sleep(window), batch.full.await).pipe(
1048
1073
  Effect.andThen(Effect.suspend(() => {
1049
1074
  closeBatch(clientId, batch)
1050
- return exchange.send(clientId, batch.requests)
1075
+ return withBatchSpan(exchange.send(clientId, batch.requests), batch.requests)
1051
1076
  })),
1052
1077
  Effect.onExit((exit) => {
1053
1078
  closeBatch(clientId, batch)
@@ -15,7 +15,7 @@ import * as Effect from "../Effect.ts"
15
15
  import { identity } from "../Function.ts"
16
16
  import type { Headers } from "../http/Headers.ts"
17
17
  import * as Layer from "../Layer.ts"
18
- import type { Pipeable } from "../Pipeable.ts"
18
+ import { type Pipeable, pipeArguments } from "../Pipeable.ts"
19
19
  import type * as Queue from "../Queue.ts"
20
20
  import type * as Record from "../Record.ts"
21
21
  import type { Scope } from "../Scope.ts"
@@ -394,6 +394,9 @@ const RpcGroupProto = {
394
394
  requests,
395
395
  annotations: this.annotations
396
396
  })
397
+ },
398
+ pipe() {
399
+ return pipeArguments(this, arguments)
397
400
  }
398
401
  }
399
402
 
@@ -271,16 +271,7 @@ ORDER BY migration_id`,
271
271
  orElse: () => Effect.void
272
272
  })
273
273
 
274
- const [latestMigrationId, current] = yield* Effect.all([
275
- Effect.map(
276
- latestMigration,
277
- Option.match({
278
- onNone: () => 0,
279
- onSome: (_) => _.id
280
- })
281
- ),
282
- loader
283
- ])
274
+ const [latest, current] = yield* Effect.all([latestMigration, loader])
284
275
 
285
276
  if (new Set(current.map(([id]) => id)).size !== current.length) {
286
277
  return yield* new MigrationError({
@@ -293,7 +284,7 @@ ORDER BY migration_id`,
293
284
 
294
285
  for (const resolved of current) {
295
286
  const [currentId, currentName] = resolved
296
- if (currentId <= latestMigrationId) {
287
+ if (Option.isSome(latest) && currentId <= latest.value.id) {
297
288
  continue
298
289
  }
299
290
 
@@ -746,16 +746,22 @@ export const makeWithTransaction = <I, S>(options: {
746
746
  Effect.flatMap(() => {
747
747
  const level = [conn, id] as const
748
748
  afterCommitBuffers.set(level, buffer)
749
+ const transactionContext = services.pipe(
750
+ Context.add(options.transactionService, level),
751
+ Context.add(CurrentTransactionService, options.transactionService),
752
+ reactivity ? Context.add(Reactivity, deferInvalidations(reactivity)) : identity,
753
+ Context.add(transactionSemaphore, Semaphore.makeUnsafe(1)),
754
+ Context.add(Tracer.ParentSpan, span)
755
+ )
749
756
  return Effect.onExitPrimitive(
750
- Effect.provideContext(
757
+ Effect.updateContext(
751
758
  restore(effect),
752
- services.pipe(
753
- Context.add(options.transactionService, level),
754
- Context.add(CurrentTransactionService, options.transactionService),
755
- reactivity ? Context.add(Reactivity, deferInvalidations(reactivity)) : identity,
756
- Context.add(transactionSemaphore, Semaphore.makeUnsafe(1)),
757
- Context.add(Tracer.ParentSpan, span)
758
- )
759
+ // `transactionContext` already extends `services`, so merging it
760
+ // into an unchanged fiber context would only copy every service.
761
+ (current: Context.Context<R>) =>
762
+ (current === services
763
+ ? transactionContext
764
+ : Context.merge(current, transactionContext)) as Context.Context<R>
759
765
  ),
760
766
  (exit) => {
761
767
  buffer.open = false
@@ -21,6 +21,7 @@ import type { Scope } from "../Scope.ts"
21
21
  import type * as Types from "../Types.ts"
22
22
  import * as DurableDeferred from "./DurableDeferred.ts"
23
23
  import { makeHashDigest } from "./internal/crypto.ts"
24
+ import { RetryingExecution } from "./internal/retry.ts"
24
25
  import * as Workflow from "./Workflow.ts"
25
26
  import type { WorkflowEngine, WorkflowInstance } from "./WorkflowEngine.ts"
26
27
 
@@ -220,6 +221,12 @@ const retryOnInterrupt = (
220
221
  * Retries an effect with `Effect.retry` while updating `CurrentAttempt` for
221
222
  * each attempt.
222
223
  *
224
+ * **Details**
225
+ *
226
+ * Under `Workflow.SuspendOnFailure`, failed attempts reach the retry policy
227
+ * instead of suspending immediately. If the policy is exhausted and the error
228
+ * escapes, the workflow suspends and `resume` replays the stored failures.
229
+ *
223
230
  * @stability unstable
224
231
  * @category error handling
225
232
  * @since 4.0.0
@@ -229,6 +236,12 @@ export const retry: {
229
236
  * Retries an effect with `Effect.retry` while updating `CurrentAttempt` for
230
237
  * each attempt.
231
238
  *
239
+ * **Details**
240
+ *
241
+ * Under `Workflow.SuspendOnFailure`, failed attempts reach the retry policy
242
+ * instead of suspending immediately. If the policy is exhausted and the error
243
+ * escapes, the workflow suspends and `resume` replays the stored failures.
244
+ *
232
245
  * @stability unstable
233
246
  * @category error handling
234
247
  * @since 4.0.0
@@ -238,6 +251,12 @@ export const retry: {
238
251
  * Retries an effect with `Effect.retry` while updating `CurrentAttempt` for
239
252
  * each attempt.
240
253
  *
254
+ * **Details**
255
+ *
256
+ * Under `Workflow.SuspendOnFailure`, failed attempts reach the retry policy
257
+ * instead of suspending immediately. If the policy is exhausted and the error
258
+ * escapes, the workflow suspends and `resume` replays the stored failures.
259
+ *
241
260
  * @stability unstable
242
261
  * @category error handling
243
262
  * @since 4.0.0
@@ -246,9 +265,12 @@ export const retry: {
246
265
  } = dual(
247
266
  2,
248
267
  (effect: Effect.Effect<any, any, any>, options: {}) =>
249
- Effect.suspend(() => {
268
+ Effect.contextWith((context: Context.Context<never>) => {
250
269
  let attempt = 1
251
- return Effect.suspend(() => Effect.provideService(effect, CurrentAttempt, attempt++)).pipe(Effect.retry(options))
270
+ return Effect.suspend(() => Effect.provideService(effect, CurrentAttempt, attempt++)).pipe(
271
+ Effect.provideService(RetryingExecution, Context.getOrUndefined(context, InstanceTag)?.executionId),
272
+ Effect.retry(options)
273
+ )
252
274
  })
253
275
  )
254
276
 
@@ -343,11 +365,13 @@ const makeExecute = Effect.fnUntraced(function*<
343
365
  const attempt = yield* CurrentAttempt
344
366
  yield* Effect.annotateCurrentSpan({ executionId: instance.executionId })
345
367
  const result = yield* Workflow.wrapActivityResult(
346
- engine.activityExecute(activity, attempt),
368
+ Effect.map(engine.activityExecute(activity, attempt), (result) => {
369
+ if (result._tag === "Suspended" && result.failed) instance.failed = true
370
+ return result
371
+ }),
347
372
  (_) => _._tag === "Suspended"
348
373
  )
349
374
  if (result._tag === "Suspended") {
350
- if (result.failed) instance.failed = true
351
375
  return yield* Workflow.suspend(instance)
352
376
  }
353
377
  return yield* result.exit
@@ -31,6 +31,8 @@ import * as SchemaParser from "../SchemaParser.ts"
31
31
  import * as Tranformation from "../SchemaTransformation.ts"
32
32
  import * as Scope from "../Scope.ts"
33
33
  import { makeHashDigest } from "./internal/crypto.ts"
34
+ import { RetryingExecution } from "./internal/retry.ts"
35
+ import { isScopeAbandoned, markScopeAbandoned } from "./internal/scope.ts"
34
36
  import type { WorkflowEngine, WorkflowInstance } from "./WorkflowEngine.ts"
35
37
 
36
38
  const TypeId = "~effect/workflow/Workflow"
@@ -84,18 +86,14 @@ export interface Workflow<
84
86
  * `discard: true` returns the execution ID without waiting for the result.
85
87
  * The child remains linked to its parent for completion wakes and interruption.
86
88
  *
87
- * With `discard: true, detached: true`, the child neither wakes its parent
88
- * nor gets interrupted with it. The cluster engine retains the parent for
89
- * observability.
89
+ * With `discard: true, detached: true`, that call does not register the caller
90
+ * for completion wakes or interruption linkage. A later non-detached call for
91
+ * the same execution still registers its caller for a completion wake. The
92
+ * cluster engine retains the parent for observability.
90
93
  *
91
94
  * Inside a workflow, an awaited child that is interrupted fails the parent
92
95
  * with a defect rather than an interrupt, so the parent can recover with
93
96
  * `Effect.catchDefect` or `Effect.exit`.
94
- *
95
- * **Gotchas**
96
- *
97
- * Do not await a detached execution later. Executing the same payload joins
98
- * it, but its completion will not wake the awaiting workflow.
99
97
  */
100
98
  readonly execute: <const Discard extends boolean = false>(
101
99
  payload: Payload["~type.make.in"],
@@ -375,7 +373,9 @@ const Proto = {
375
373
  ) {
376
374
  return Effect.suspend(() => {
377
375
  const payload = this.payloadSchema.make(fields)
378
- const run = Effect.flatMap(
376
+ // Register with the parent before the execution id is computed, so a
377
+ // sibling that suspends first waits for this child to be dispatched.
378
+ return withPendingActivity(Effect.flatMap(
379
379
  EngineTag,
380
380
  (engine) =>
381
381
  Effect.flatMap(makeExecutionIdFromPayload(this, payload), (executionId) =>
@@ -389,10 +389,7 @@ const Proto = {
389
389
  suspendedRetrySchedule: this.suspendedRetrySchedule
390
390
  })
391
391
  ))
392
- )
393
- // Register with the parent before the execution id is computed, so a
394
- // sibling that suspends first waits for this child to be dispatched.
395
- return opts?.discard ? run : withPendingActivity(run)
392
+ ))
396
393
  }).pipe(
397
394
  Effect.withSpan(
398
395
  `${this._tag}.execute`,
@@ -715,7 +712,9 @@ export const intoResult = <A, E, R>(
715
712
  Effect.contextWith((context: Context.Context<WorkflowInstance>) => {
716
713
  const instance = Context.get(context, InstanceTag)
717
714
  const captureDefects = Context.get(instance.workflow.annotations, CaptureDefects)
718
- const suspendOnFailure = Context.get(instance.workflow.annotations, SuspendOnFailure)
715
+ // Inside `Activity.retry` a failure goes to the retry policy instead.
716
+ const suspendOnFailure = Context.get(instance.workflow.annotations, SuspendOnFailure) &&
717
+ Context.get(context, RetryingExecution) !== instance.executionId
719
718
  return effect.pipe(
720
719
  Effect.forkChild({ startImmediately: true }),
721
720
  // The outer uninterruptible region protects the fork and cancellation hook.
@@ -749,6 +748,11 @@ export const intoResult = <A, E, R>(
749
748
  const filtered = reasons.length === 0 ? cause : Cause.fromReasons(reasons)
750
749
  const abandoned = instance.abandoned && !instance.interrupted && hasInterruptsOnly
751
750
  instance.abandoned = abandoned
751
+ if (abandoned) {
752
+ // Superseded instances can share this scope, which closes before
753
+ // the engine marks its parent.
754
+ markScopeAbandoned(instance.scope)
755
+ }
752
756
  if (instance.suspended && hasInterruptsOnly && !abandoned) {
753
757
  return Effect.succeed(
754
758
  new Suspended(instance.failed ? { cause: instance.cause, failed: true } : { cause: instance.cause })
@@ -767,14 +771,27 @@ export const intoResult = <A, E, R>(
767
771
  }
768
772
  }),
769
773
  (eff) =>
770
- Effect.onExitPrimitive(eff, (exit) => {
771
- if (Exit.isFailure(exit)) {
772
- return Scope.close(instance.scope, exit)
773
- } else if (exit.value._tag === "Complete") {
774
- return Scope.close(instance.scope, exit.value.exit)
775
- }
776
- return Effect.void
777
- }, true),
774
+ Effect.onExitPrimitive(
775
+ eff,
776
+ (exit) => Exit.isFailure(exit) ? Scope.close(instance.scope, exit) : undefined,
777
+ true
778
+ ),
779
+ Effect.flatMap((result): Effect.Effect<Result<A, E>> => {
780
+ if (result._tag !== "Complete") {
781
+ return Effect.succeed(result)
782
+ }
783
+ const close = Effect.as(Scope.close(instance.scope, result.exit), result)
784
+ return captureDefects
785
+ ? Effect.catchCauseIf(close, Cause.hasDies, (closeCause) =>
786
+ Effect.succeed(
787
+ new Complete({
788
+ exit: Exit.failCause(
789
+ Exit.isFailure(result.exit) ? Cause.combine(result.exit.cause, closeCause) : closeCause
790
+ )
791
+ })
792
+ ))
793
+ : close
794
+ }),
778
795
  Effect.uninterruptible
779
796
  )
780
797
  })
@@ -796,23 +813,22 @@ export const wrapActivityResult = <A, E, R>(
796
813
  return Effect.acquireUseRelease(
797
814
  Effect.sync(() => adoptActivityUnsafe(context, instance) ?? registerActivityUnsafe(instance)),
798
815
  () => effect,
799
- (registration, exit) => {
800
- releaseActivityUnsafe(registration)
801
- const isSuspended = Exit.isSuccess(exit) && isSuspend(exit.value)
802
- if (
803
- Exit.isSuccess(exit) &&
804
- isResult(exit.value) &&
805
- exit.value._tag === "Suspended" &&
806
- exit.value.cause
807
- ) {
808
- instance.cause = instance.cause
809
- ? Cause.combine(instance.cause, exit.value.cause)
810
- : exit.value.cause
811
- }
812
- return isSuspended && instance.activityState.count > 0
813
- ? waitForZero(instance)
814
- : Effect.void
815
- }
816
+ (registration, exit) =>
817
+ Effect.sync(() => {
818
+ releaseActivityUnsafe(registration)
819
+ if (
820
+ Exit.isSuccess(exit) &&
821
+ isResult(exit.value) &&
822
+ exit.value._tag === "Suspended" &&
823
+ exit.value.cause
824
+ ) {
825
+ instance.cause = instance.cause
826
+ ? Cause.combine(instance.cause, exit.value.cause)
827
+ : exit.value.cause
828
+ }
829
+ })
830
+ ).pipe(
831
+ Effect.tap((value) => isSuspend(value) ? waitForZero(instance) : Effect.void)
816
832
  )
817
833
  })
818
834
 
@@ -856,9 +872,9 @@ const releaseActivityUnsafe = (registration: ActivityRegistration) => {
856
872
  }
857
873
 
858
874
  /**
859
- * Registers a pending child workflow execution with the current workflow
860
- * instance before any asynchronous work runs. `wrapActivityResult` adopts the
861
- * registration once the execution is dispatched.
875
+ * Registers a pending child workflow with the current instance before async
876
+ * work runs. Awaited starts are adopted by `wrapActivityResult`; discarded
877
+ * starts release when dispatch returns.
862
878
  */
863
879
  const withPendingActivity = <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
864
880
  Effect.contextWith((context: Context.Context<never>) => {
@@ -941,7 +957,10 @@ export const addFinalizer: <R>(
941
957
  const services = yield* Effect.context<R>()
942
958
  yield* Scope.addFinalizerExit(
943
959
  instance.scope,
944
- (exit) => instance.abandoned ? Effect.void : Effect.provideContext(f(exit), services)
960
+ (exit) =>
961
+ instance.abandoned || isScopeAbandoned(instance.scope)
962
+ ? Effect.void
963
+ : Effect.provideContext(f(exit), services)
945
964
  )
946
965
  })
947
966
 
@@ -1064,7 +1083,12 @@ export const CaptureDefects = Context.Reference<boolean>(
1064
1083
  *
1065
1084
  * **Details**
1066
1085
  *
1067
- * The suspended execution can later be resumed with the workflow's `resume` method, for example `MyWorkflow.resume(executionId)`.
1086
+ * The suspended execution can later be resumed with the workflow's `resume`
1087
+ * method, for example `MyWorkflow.resume(executionId)`.
1088
+ *
1089
+ * Inside `Activity.retry`, failed attempts reach the retry policy instead of
1090
+ * suspending immediately; if the policy is exhausted and the error escapes,
1091
+ * the workflow suspends and `resume` replays the stored failures.
1068
1092
  *
1069
1093
  * @stability unstable
1070
1094
  * @category services