effect 4.0.0-beta.83 → 4.0.0-beta.85

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 (235) hide show
  1. package/dist/Array.d.ts +64 -64
  2. package/dist/Array.js +26 -26
  3. package/dist/Cache.d.ts +1 -1
  4. package/dist/Cache.js +1 -1
  5. package/dist/Cause.d.ts +68 -68
  6. package/dist/Cause.js +47 -47
  7. package/dist/Channel.d.ts +5 -5
  8. package/dist/Channel.js +3 -3
  9. package/dist/Clock.d.ts +1 -1
  10. package/dist/Clock.js +1 -1
  11. package/dist/Combiner.d.ts +9 -9
  12. package/dist/Combiner.js +8 -8
  13. package/dist/Config.d.ts +15 -94
  14. package/dist/Config.d.ts.map +1 -1
  15. package/dist/Config.js +22 -70
  16. package/dist/Config.js.map +1 -1
  17. package/dist/ConfigProvider.d.ts +58 -74
  18. package/dist/ConfigProvider.d.ts.map +1 -1
  19. package/dist/ConfigProvider.js +66 -41
  20. package/dist/ConfigProvider.js.map +1 -1
  21. package/dist/Console.d.ts +1 -1
  22. package/dist/Console.js +1 -1
  23. package/dist/Context.d.ts.map +1 -1
  24. package/dist/Context.js +4 -3
  25. package/dist/Context.js.map +1 -1
  26. package/dist/Data.d.ts +15 -15
  27. package/dist/Data.js +3 -3
  28. package/dist/DateTime.d.ts +6 -6
  29. package/dist/DateTime.js +2 -2
  30. package/dist/Duration.d.ts +3 -3
  31. package/dist/Duration.js +3 -3
  32. package/dist/Effect.d.ts +84 -45
  33. package/dist/Effect.d.ts.map +1 -1
  34. package/dist/Effect.js +72 -33
  35. package/dist/Effect.js.map +1 -1
  36. package/dist/Equal.d.ts +7 -7
  37. package/dist/Equal.js +5 -5
  38. package/dist/Equivalence.d.ts +17 -17
  39. package/dist/Equivalence.js +13 -13
  40. package/dist/Exit.d.ts +3 -3
  41. package/dist/Exit.js +3 -3
  42. package/dist/Formatter.d.ts +5 -5
  43. package/dist/Formatter.js +4 -4
  44. package/dist/Function.d.ts +10 -10
  45. package/dist/Function.js +3 -3
  46. package/dist/HashMap.d.ts +3 -3
  47. package/dist/HashMap.js +1 -1
  48. package/dist/Iterable.d.ts +6 -6
  49. package/dist/Iterable.js +2 -2
  50. package/dist/JsonPatch.d.ts +2 -2
  51. package/dist/Layer.d.ts +1 -1
  52. package/dist/Layer.js +5 -4
  53. package/dist/Layer.js.map +1 -1
  54. package/dist/LayerMap.d.ts.map +1 -1
  55. package/dist/LayerMap.js +4 -3
  56. package/dist/LayerMap.js.map +1 -1
  57. package/dist/Logger.d.ts +1 -1
  58. package/dist/Logger.js +1 -1
  59. package/dist/Match.d.ts +8 -8
  60. package/dist/Match.js +8 -8
  61. package/dist/Metric.d.ts +3 -3
  62. package/dist/Metric.js +3 -3
  63. package/dist/Optic.d.ts +30 -30
  64. package/dist/Optic.js +12 -12
  65. package/dist/Option.d.ts +7 -7
  66. package/dist/Option.js +7 -7
  67. package/dist/Order.d.ts +23 -23
  68. package/dist/Order.js +20 -20
  69. package/dist/Pool.d.ts +1 -1
  70. package/dist/Pool.js +1 -1
  71. package/dist/Predicate.d.ts +88 -88
  72. package/dist/Predicate.js +47 -47
  73. package/dist/PubSub.d.ts +3 -3
  74. package/dist/PubSub.js +3 -3
  75. package/dist/Random.d.ts +31 -0
  76. package/dist/Random.d.ts.map +1 -1
  77. package/dist/Random.js +32 -0
  78. package/dist/Random.js.map +1 -1
  79. package/dist/Reducer.d.ts +1 -1
  80. package/dist/Reducer.js +1 -1
  81. package/dist/Result.d.ts +18 -18
  82. package/dist/Result.js +8 -8
  83. package/dist/Runtime.d.ts +1 -1
  84. package/dist/Runtime.js +1 -1
  85. package/dist/Schema.d.ts +313 -126
  86. package/dist/Schema.d.ts.map +1 -1
  87. package/dist/Schema.js +316 -127
  88. package/dist/Schema.js.map +1 -1
  89. package/dist/SchemaAST.d.ts +9 -8
  90. package/dist/SchemaAST.d.ts.map +1 -1
  91. package/dist/SchemaAST.js +203 -140
  92. package/dist/SchemaAST.js.map +1 -1
  93. package/dist/SchemaGetter.d.ts +48 -48
  94. package/dist/SchemaGetter.js +44 -44
  95. package/dist/SchemaIssue.d.ts +3 -3
  96. package/dist/SchemaIssue.js +3 -3
  97. package/dist/SchemaParser.d.ts +122 -22
  98. package/dist/SchemaParser.d.ts.map +1 -1
  99. package/dist/SchemaParser.js +186 -50
  100. package/dist/SchemaParser.js.map +1 -1
  101. package/dist/SchemaRepresentation.d.ts +1 -1
  102. package/dist/SchemaRepresentation.d.ts.map +1 -1
  103. package/dist/SchemaRepresentation.js +96 -2
  104. package/dist/SchemaRepresentation.js.map +1 -1
  105. package/dist/SchemaTransformation.d.ts +20 -20
  106. package/dist/SchemaTransformation.js +18 -18
  107. package/dist/Stream.d.ts +3 -3
  108. package/dist/Stream.js +2 -2
  109. package/dist/Stream.js.map +1 -1
  110. package/dist/String.d.ts +1 -1
  111. package/dist/String.js +1 -1
  112. package/dist/Struct.d.ts +1 -1
  113. package/dist/Struct.js +1 -1
  114. package/dist/Types.d.ts +13 -13
  115. package/dist/internal/effect.js +33 -20
  116. package/dist/internal/effect.js.map +1 -1
  117. package/dist/internal/schema/arbitrary.js +17 -1
  118. package/dist/internal/schema/arbitrary.js.map +1 -1
  119. package/dist/internal/schema/cause.d.ts +2 -0
  120. package/dist/internal/schema/cause.d.ts.map +1 -0
  121. package/dist/internal/schema/cause.js +24 -0
  122. package/dist/internal/schema/cause.js.map +1 -0
  123. package/dist/internal/schema/schema.d.ts +8 -4
  124. package/dist/internal/schema/schema.d.ts.map +1 -1
  125. package/dist/internal/schema/schema.js +21 -8
  126. package/dist/internal/schema/schema.js.map +1 -1
  127. package/dist/internal/stackTraceLimit.d.ts +2 -0
  128. package/dist/internal/stackTraceLimit.d.ts.map +1 -0
  129. package/dist/internal/stackTraceLimit.js +40 -0
  130. package/dist/internal/stackTraceLimit.js.map +1 -0
  131. package/dist/internal/tracer.d.ts.map +1 -1
  132. package/dist/internal/tracer.js +4 -3
  133. package/dist/internal/tracer.js.map +1 -1
  134. package/dist/testing/TestSchema.d.ts +3 -3
  135. package/dist/testing/TestSchema.js +1 -1
  136. package/dist/unstable/ai/AiError.d.ts +1 -1
  137. package/dist/unstable/ai/AiError.js +1 -1
  138. package/dist/unstable/ai/Chat.d.ts +1 -1
  139. package/dist/unstable/ai/Chat.js +1 -1
  140. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  141. package/dist/unstable/ai/Tool.js +4 -5
  142. package/dist/unstable/ai/Tool.js.map +1 -1
  143. package/dist/unstable/cli/Prompt.js +2 -2
  144. package/dist/unstable/cli/Prompt.js.map +1 -1
  145. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
  146. package/dist/unstable/httpapi/HttpApiMiddleware.js +4 -3
  147. package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
  148. package/dist/unstable/httpapi/HttpApiScalar.d.ts +2 -2
  149. package/dist/unstable/persistence/PersistedQueue.js +1 -1
  150. package/dist/unstable/rpc/Rpc.d.ts +1 -1
  151. package/dist/unstable/rpc/Rpc.js +1 -1
  152. package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
  153. package/dist/unstable/rpc/RpcGroup.js +3 -4
  154. package/dist/unstable/rpc/RpcGroup.js.map +1 -1
  155. package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
  156. package/dist/unstable/rpc/RpcMiddleware.js +4 -3
  157. package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
  158. package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
  159. package/dist/unstable/sql/SqlResolver.js +15 -2
  160. package/dist/unstable/sql/SqlResolver.js.map +1 -1
  161. package/dist/unstable/workflow/Activity.d.ts +1 -0
  162. package/dist/unstable/workflow/Activity.d.ts.map +1 -1
  163. package/dist/unstable/workflow/Activity.js +1 -0
  164. package/dist/unstable/workflow/Activity.js.map +1 -1
  165. package/dist/unstable/workflow/WorkflowEngine.js +1 -1
  166. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  167. package/package.json +1 -1
  168. package/src/Array.ts +65 -65
  169. package/src/Cache.ts +1 -1
  170. package/src/Cause.ts +68 -68
  171. package/src/Channel.ts +5 -5
  172. package/src/Clock.ts +1 -1
  173. package/src/Combiner.ts +9 -9
  174. package/src/Config.ts +40 -108
  175. package/src/ConfigProvider.ts +139 -100
  176. package/src/Console.ts +1 -1
  177. package/src/Context.ts +4 -5
  178. package/src/Data.ts +15 -15
  179. package/src/DateTime.ts +6 -6
  180. package/src/Duration.ts +3 -3
  181. package/src/Effect.ts +89 -45
  182. package/src/Equal.ts +7 -7
  183. package/src/Equivalence.ts +17 -17
  184. package/src/Exit.ts +3 -3
  185. package/src/Formatter.ts +5 -5
  186. package/src/Function.ts +10 -10
  187. package/src/HashMap.ts +3 -3
  188. package/src/Iterable.ts +6 -6
  189. package/src/JsonPatch.ts +2 -2
  190. package/src/Layer.ts +5 -5
  191. package/src/LayerMap.ts +4 -3
  192. package/src/Logger.ts +1 -1
  193. package/src/Match.ts +8 -8
  194. package/src/Metric.ts +3 -3
  195. package/src/Optic.ts +30 -30
  196. package/src/Option.ts +7 -7
  197. package/src/Order.ts +23 -23
  198. package/src/Pool.ts +1 -1
  199. package/src/Predicate.ts +88 -88
  200. package/src/PubSub.ts +3 -3
  201. package/src/Random.ts +42 -0
  202. package/src/Reducer.ts +1 -1
  203. package/src/Result.ts +20 -20
  204. package/src/Runtime.ts +1 -1
  205. package/src/Schema.ts +389 -153
  206. package/src/SchemaAST.ts +237 -148
  207. package/src/SchemaGetter.ts +48 -48
  208. package/src/SchemaIssue.ts +3 -3
  209. package/src/SchemaParser.ts +197 -58
  210. package/src/SchemaRepresentation.ts +73 -3
  211. package/src/SchemaTransformation.ts +20 -20
  212. package/src/Stream.ts +4 -4
  213. package/src/String.ts +1 -1
  214. package/src/Struct.ts +1 -1
  215. package/src/Types.ts +13 -13
  216. package/src/internal/effect.ts +40 -21
  217. package/src/internal/schema/arbitrary.ts +23 -2
  218. package/src/internal/schema/cause.ts +26 -0
  219. package/src/internal/schema/schema.ts +36 -10
  220. package/src/internal/stackTraceLimit.ts +63 -0
  221. package/src/internal/tracer.ts +4 -3
  222. package/src/testing/TestSchema.ts +3 -3
  223. package/src/unstable/ai/AiError.ts +1 -1
  224. package/src/unstable/ai/Chat.ts +1 -1
  225. package/src/unstable/ai/Tool.ts +4 -3
  226. package/src/unstable/cli/Prompt.ts +1 -1
  227. package/src/unstable/httpapi/HttpApiMiddleware.ts +4 -3
  228. package/src/unstable/httpapi/HttpApiScalar.ts +2 -2
  229. package/src/unstable/persistence/PersistedQueue.ts +1 -1
  230. package/src/unstable/rpc/Rpc.ts +1 -1
  231. package/src/unstable/rpc/RpcGroup.ts +3 -4
  232. package/src/unstable/rpc/RpcMiddleware.ts +4 -3
  233. package/src/unstable/sql/SqlResolver.ts +15 -2
  234. package/src/unstable/workflow/Activity.ts +2 -0
  235. package/src/unstable/workflow/WorkflowEngine.ts +1 -1
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Utility for safely manipulating `Error.stackTraceLimit` in environments
3
+ * where intrinsics may be frozen (e.g., SES / hardened JavaScript or
4
+ * deterministic sandboxes such as Temporal). When the property is non-writable,
5
+ * mutating it throws, so all manipulation here degrades to a best-effort,
6
+ * silent no-op.
7
+ *
8
+ * Mirrors the guard Node uses internally:
9
+ * https://github.com/nodejs/node/blob/e77694631f1642c302f664703197b5aabc65b482/lib/internal/errors.js#L246
10
+ *
11
+ * The error is constructed inline at each call site (rather than inside a
12
+ * closure here) so the captured stack trace keeps pointing at the real caller
13
+ * instead of this module.
14
+ *
15
+ * @internal
16
+ */
17
+ import type { ErrorWithStackTraceLimit } from "./tracer.ts"
18
+
19
+ const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor
20
+ const ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty
21
+ const ObjectIsExtensible = Object.isExtensible
22
+
23
+ /**
24
+ * Check if `Error.stackTraceLimit` is writable.
25
+ * Returns `false` if the property is frozen, non-writable, or `Error` is non-extensible.
26
+ *
27
+ * @internal
28
+ */
29
+ export const isStackTraceLimitWritable = (): boolean => {
30
+ const desc = ObjectGetOwnPropertyDescriptor(Error, "stackTraceLimit")
31
+ if (desc === undefined) {
32
+ return ObjectIsExtensible(Error)
33
+ }
34
+
35
+ return ObjectPrototypeHasOwnProperty.call(desc, "writable")
36
+ ? desc.writable === true
37
+ : desc.set !== undefined
38
+ }
39
+
40
+ // Cache the check result since it won't change during runtime
41
+ const canWriteStackTraceLimit = isStackTraceLimitWritable()
42
+
43
+ /**
44
+ * Get the current `Error.stackTraceLimit` value.
45
+ * Returns `undefined` if the property doesn't exist.
46
+ *
47
+ * @internal
48
+ */
49
+ export const getStackTraceLimit = (): number | undefined => (Error as ErrorWithStackTraceLimit).stackTraceLimit
50
+
51
+ /**
52
+ * Safely set `Error.stackTraceLimit` if possible, otherwise no-op.
53
+ *
54
+ * Accepts `undefined` so a value read via {@link getStackTraceLimit} can be
55
+ * restored faithfully.
56
+ *
57
+ * @internal
58
+ */
59
+ export const setStackTraceLimit = (value: number | undefined): void => {
60
+ if (canWriteStackTraceLimit) {
61
+ ;(Error as ErrorWithStackTraceLimit).stackTraceLimit = value
62
+ }
63
+ }
@@ -1,4 +1,5 @@
1
1
  import type * as Tracer from "../Tracer.ts"
2
+ import { getStackTraceLimit, setStackTraceLimit } from "./stackTraceLimit.ts"
2
3
 
3
4
  export interface ErrorWithStackTraceLimit {
4
5
  stackTraceLimit?: number | undefined
@@ -13,10 +14,10 @@ export const addSpanStackTrace = <A extends Tracer.TraceOptions>(
13
14
  } else if (options?.captureStackTrace !== undefined && typeof options.captureStackTrace !== "boolean") {
14
15
  return options
15
16
  }
16
- const limit = (Error as ErrorWithStackTraceLimit).stackTraceLimit
17
- ;(Error as ErrorWithStackTraceLimit).stackTraceLimit = 3
17
+ const limit = getStackTraceLimit()
18
+ setStackTraceLimit(3)
18
19
  const traceError = new Error()
19
- ;(Error as ErrorWithStackTraceLimit).stackTraceLimit = limit
20
+ setStackTraceLimit(limit)
20
21
  return {
21
22
  ...options,
22
23
  captureStackTrace: spanCleaner(() => traceError.stack)
@@ -154,7 +154,7 @@ export class Asserts<S extends Schema.Top> {
154
154
  *
155
155
  * FastCheck generates arbitrary values matching the schema's `Type`. The assertion fails if any generated value does not round-trip. Pass `options.params` to control FastCheck parameters such as `numRuns`.
156
156
  *
157
- * **Example** (Round-trip verification)
157
+ * **Example** (Verifying round trips)
158
158
  *
159
159
  * ```ts
160
160
  * import { Schema } from "effect"
@@ -338,7 +338,7 @@ export class Decoding<S extends Schema.Top> {
338
338
  *
339
339
  * Use to verify successful decoding for one input case.
340
340
  *
341
- * **Example** (Identity and transformed decoding)
341
+ * **Example** (Testing identity and transformed decoding)
342
342
  *
343
343
  * ```ts
344
344
  * import { Schema } from "effect"
@@ -478,7 +478,7 @@ export class Encoding<S extends Schema.Top> {
478
478
  *
479
479
  * Use to verify successful encoding for one input case.
480
480
  *
481
- * **Example** (Identity and transformed encoding)
481
+ * **Example** (Testing identity and transformed encoding)
482
482
  *
483
483
  * ```ts
484
484
  * import { Schema } from "effect"
@@ -181,7 +181,7 @@ export class NetworkError extends Schema.ErrorClass<NetworkError>(
181
181
  * Provider-specific metadata is namespaced by provider name. Each provider
182
182
  * value can contain arbitrary mutable JSON metadata or `null`.
183
183
  *
184
- * **Example** (Metadata shape)
184
+ * **Example** (Inspecting metadata shape)
185
185
  *
186
186
  * ```ts
187
187
  * const metadata = {
@@ -46,7 +46,7 @@ import type * as Tool from "./Tool.ts"
46
46
  * enabling persistent conversational AI interactions with full context
47
47
  * management.
48
48
  *
49
- * **Example** (Using the Chat service)
49
+ * **Example** (Accessing the Chat service)
50
50
  *
51
51
  * ```ts
52
52
  * import { Effect } from "effect"
@@ -14,6 +14,7 @@
14
14
  import * as Context from "../../Context.ts"
15
15
  import type * as Effect from "../../Effect.ts"
16
16
  import { constFalse, constTrue, identity } from "../../Function.ts"
17
+ import * as StackTraceLimit from "../../internal/stackTraceLimit.ts"
17
18
  import type * as JsonSchema from "../../JsonSchema.ts"
18
19
  import { pipeArguments } from "../../Pipeable.ts"
19
20
  import * as Predicate from "../../Predicate.ts"
@@ -1997,12 +1998,12 @@ function filter(obj: any) {
1997
1998
  */
1998
1999
  export const unsafeSecureJsonParse = (text: string): unknown => {
1999
2000
  // Performance optimization, see https://github.com/fastify/secure-json-parse/pull/90
2000
- const { stackTraceLimit } = Error
2001
- Error.stackTraceLimit = 0
2001
+ const prevLimit = StackTraceLimit.getStackTraceLimit()
2002
+ StackTraceLimit.setStackTraceLimit(0)
2002
2003
  try {
2003
2004
  return _parse(text)
2004
2005
  } finally {
2005
- Error.stackTraceLimit = stackTraceLimit
2006
+ StackTraceLimit.setStackTraceLimit(prevLimit)
2006
2007
  }
2007
2008
  }
2008
2009
 
@@ -1422,7 +1422,7 @@ const runLoop = Effect.fnUntraced(
1422
1422
  yield* Effect.orDie(terminal.display(msg))
1423
1423
  if (loop.events) {
1424
1424
  const takeInput = Queue.take(input).pipe(
1425
- Effect.map((event) => ({ _tag: "Input" as const, event }))
1425
+ Effect.map((input) => ({ _tag: "Input" as const, input }))
1426
1426
  )
1427
1427
  const result = yield* Effect.raceFirst(
1428
1428
  takeInput,
@@ -15,6 +15,7 @@
15
15
  /** @effect-diagnostics classSelfMismatch:off */
16
16
  import * as Context from "../../Context.ts"
17
17
  import * as Effect from "../../Effect.ts"
18
+ import { getStackTraceLimit, setStackTraceLimit } from "../../internal/stackTraceLimit.ts"
18
19
  import * as Layer from "../../Layer.ts"
19
20
  import { hasProperty } from "../../Predicate.ts"
20
21
  import type * as Schema from "../../Schema.ts"
@@ -352,10 +353,10 @@ export const Service = <
352
353
  } | undefined
353
354
  ) => {
354
355
  const Err = globalThis.Error as any
355
- const limit = Err.stackTraceLimit
356
- Err.stackTraceLimit = 2
356
+ const limit = getStackTraceLimit()
357
+ setStackTraceLimit(2)
357
358
  const creationError = new Err()
358
- Err.stackTraceLimit = limit
359
+ setStackTraceLimit(limit)
359
360
 
360
361
  class Service extends Context.Service<Self, any>()(id) {}
361
362
  const self = Service as any
@@ -87,7 +87,7 @@ export type ScalarConfig = {
87
87
  /**
88
88
  * Path to a favicon image.
89
89
  *
90
- * **Example** (Relative favicon)
90
+ * **Example** (Setting a relative favicon)
91
91
  *
92
92
  * ```ts
93
93
  * const favicon = "/favicon.svg"
@@ -107,7 +107,7 @@ export type ScalarConfig = {
107
107
  * Browsers can derive the origin from `window.location.origin`; server
108
108
  * rendering needs this value supplied explicitly.
109
109
  *
110
- * **Example** (Local server URL)
110
+ * **Example** (Setting a local server URL)
111
111
  *
112
112
  * ```ts
113
113
  * const baseServerURL = "http://localhost:3000"
@@ -508,7 +508,7 @@ export const makeStoreRedis = Effect.fnUntraced(function*(
508
508
  id,
509
509
  JSON.stringify({ id, element, attempts: 0 })
510
510
  )
511
- : redis.send("LPUSH", `${prefix}${name}`, JSON.stringify({ id, element, attempts: 0 })),
511
+ : redis.send("RPUSH", `${prefix}${name}`, JSON.stringify({ id, element, attempts: 0 })),
512
512
  ({ cause }) =>
513
513
  new PersistedQueueError({
514
514
  message: "Failed to offer element to persisted queue",
@@ -955,7 +955,7 @@ export const make = <
955
955
  /**
956
956
  * Creates a custom `Rpc` constructor that can transform the output schemas.
957
957
  *
958
- * **Example** (Paginated RPC constructor)
958
+ * **Example** (Defining a paginated RPC constructor)
959
959
  *
960
960
  * ```ts
961
961
  * import { Schema } from "effect"
@@ -303,14 +303,13 @@ const RpcGroupProto = {
303
303
  const services = yield* Effect.context<never>()
304
304
  const handlers = Effect.isEffect(build) ? yield* build : build
305
305
  const contextMap = new Map<string, unknown>()
306
- for (const [tag, handler] of Object.entries(handlers)) {
307
- const rpc = self.requests.get(tag)!
306
+ self.requests.forEach((rpc, tag) => {
308
307
  contextMap.set(rpc.key, {
309
308
  tag: rpc._tag,
310
- handler,
309
+ handler: handlers[tag],
311
310
  context: services
312
311
  })
313
- }
312
+ })
314
313
  return Context.makeUnsafe(contextMap)
315
314
  })
316
315
  },
@@ -11,6 +11,7 @@
11
11
  */
12
12
  import * as Context from "../../Context.ts"
13
13
  import * as Effect from "../../Effect.ts"
14
+ import { getStackTraceLimit, setStackTraceLimit } from "../../internal/stackTraceLimit.ts"
14
15
  import * as Layer from "../../Layer.ts"
15
16
  import * as Schema from "../../Schema.ts"
16
17
  import { Scope } from "../../Scope.ts"
@@ -292,10 +293,10 @@ export const Service = <
292
293
  }
293
294
  ) => {
294
295
  const Err = globalThis.Error as any
295
- const limit = Err.stackTraceLimit
296
- Err.stackTraceLimit = 2
296
+ const limit = getStackTraceLimit()
297
+ setStackTraceLimit(2)
297
298
  const creationError = new Err()
298
- Err.stackTraceLimit = limit
299
+ setStackTraceLimit(limit)
299
300
 
300
301
  function ServiceClass() {}
301
302
  const ServiceClass_ = ServiceClass as any as Mutable<AnyService>
@@ -17,6 +17,7 @@ import * as Equal from "../../Equal.ts"
17
17
  import * as Exit from "../../Exit.ts"
18
18
  import * as Hash from "../../Hash.ts"
19
19
  import * as MutableHashMap from "../../MutableHashMap.ts"
20
+ import * as Option from "../../Option.ts"
20
21
  import * as Request from "../../Request.ts"
21
22
  import * as RequestResolver from "../../RequestResolver.ts"
22
23
  import * as Schema from "../../Schema.ts"
@@ -376,8 +377,20 @@ const partitionRequestsById = function*<In, A, E, R, InE>(
376
377
 
377
378
  for (let i = 0; i < len; i++) {
378
379
  entry = requests[i]
379
- yield (Effect.provideContext(handle(encode(entry.request.payload)), entry.context) as Effect.Effect<void>)
380
- MutableHashMap.set(byIdMap, entry.request.payload, entry)
380
+ const existing = MutableHashMap.get(byIdMap, entry.request.payload)
381
+ if (Option.isSome(existing)) {
382
+ const duplicate = entry
383
+ MutableHashMap.set(byIdMap, entry.request.payload, {
384
+ ...existing.value,
385
+ completeUnsafe(exit) {
386
+ existing.value.completeUnsafe(exit)
387
+ duplicate.completeUnsafe(exit)
388
+ }
389
+ })
390
+ } else {
391
+ yield (Effect.provideContext(handle(encode(entry.request.payload)), entry.context) as Effect.Effect<void>)
392
+ MutableHashMap.set(byIdMap, entry.request.payload, entry)
393
+ }
381
394
  }
382
395
 
383
396
  return [inputs, byIdMap] as const
@@ -49,6 +49,7 @@ export interface Activity<
49
49
  readonly successSchema: Success
50
50
  readonly errorSchema: Error
51
51
  readonly exitSchema: Schema.Exit<Success, Error, Schema.Defect>
52
+ readonly exitSchemaPartial: Schema.Exit<Success, Error, Schema.Unknown>
52
53
  readonly annotations: Context.Context<never>
53
54
  annotate<I, S>(
54
55
  key: Context.Key<I, S>,
@@ -153,6 +154,7 @@ export const make = <
153
154
  successSchema,
154
155
  errorSchema,
155
156
  exitSchema: Schema.Exit(successSchemaJson, errorSchemaJson, Schema.Defect()),
157
+ exitSchemaPartial: Schema.Exit(successSchemaJson, errorSchemaJson, Schema.Unknown),
156
158
  annotations: options.annotations ?? Context.empty(),
157
159
  annotate(tag: Context.Key<any, any>, value: any) {
158
160
  return make({
@@ -478,7 +478,7 @@ export const makeUnsafe = (options: Encoded): WorkflowEngine["Service"] =>
478
478
  return result
479
479
  }
480
480
  const exit = yield* Effect.orDie(
481
- Schema.decodeEffect(activity.exitSchema)(toJsonExit(result.exit))
481
+ Schema.decodeEffect(activity.exitSchemaPartial)(toJsonExit(result.exit))
482
482
  )
483
483
  return new Workflow.Complete({ exit })
484
484
  }),