effect 3.22.2 → 3.22.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/LayerMap.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * @experimental
4
4
  */
5
5
  import * as Context from "./Context.js"
6
- import type * as Duration from "./Duration.js"
6
+ import * as Duration from "./Duration.js"
7
7
  import * as Effect from "./Effect.js"
8
8
  import * as FiberRefsPatch from "./FiberRefsPatch.js"
9
9
  import { identity } from "./Function.js"
@@ -119,6 +119,11 @@ export const make: <
119
119
  lookup: (key: K) => L,
120
120
  options?: {
121
121
  readonly idleTimeToLive?: Duration.DurationInput | undefined
122
+ /**
123
+ * Preloaded entries become idle immediately and follow the idle TTL.
124
+ * The default idle TTL is zero, so preloading only occurs when a nonzero
125
+ * `idleTimeToLive` is configured.
126
+ */
122
127
  readonly preloadKeys?: PreloadKeys
123
128
  } | undefined
124
129
  ) => Effect.Effect<
@@ -177,9 +182,13 @@ export const make: <
177
182
  idleTimeToLive: options?.idleTimeToLive
178
183
  })
179
184
 
180
- if (options?.preloadKeys) {
185
+ if (
186
+ options?.preloadKeys &&
187
+ options.idleTimeToLive !== undefined &&
188
+ !Duration.isZero(Duration.decode(options.idleTimeToLive))
189
+ ) {
181
190
  for (const key of options.preloadKeys) {
182
- yield* (RcMap.get(rcMap, key) as Effect.Effect<any, EL, RL | Scope.Scope>)
191
+ yield* Effect.scoped(RcMap.get(rcMap, key) as Effect.Effect<any, EL, RL | Scope.Scope>)
183
192
  }
184
193
  }
185
194
 
@@ -204,6 +213,11 @@ export const fromRecord = <
204
213
  layers: Layers,
205
214
  options?: {
206
215
  readonly idleTimeToLive?: Duration.DurationInput | undefined
216
+ /**
217
+ * Preloaded entries become idle immediately and follow the idle TTL.
218
+ * The default idle TTL is zero, so preloading only occurs when a nonzero
219
+ * `idleTimeToLive` is configured.
220
+ */
207
221
  readonly preload?: Preload | undefined
208
222
  } | undefined
209
223
  ): Effect.Effect<
@@ -327,6 +341,11 @@ export const Service = <Self>() =>
327
341
  readonly lookup: (key: any) => Layer.Layer<any, any, any>
328
342
  readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>>
329
343
  readonly idleTimeToLive?: Duration.DurationInput | undefined
344
+ /**
345
+ * Preloaded entries become idle immediately and follow the idle TTL.
346
+ * The default idle TTL is zero, so preloading only occurs when a nonzero
347
+ * `idleTimeToLive` is configured.
348
+ */
330
349
  readonly preloadKeys?:
331
350
  | Iterable<Options extends { readonly lookup: (key: infer K) => any } ? K : never>
332
351
  | undefined
@@ -337,6 +356,11 @@ export const Service = <Self>() =>
337
356
  readonly layers: Record<string, Layer.Layer<any, any, any>>
338
357
  readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>>
339
358
  readonly idleTimeToLive?: Duration.DurationInput | undefined
359
+ /**
360
+ * Preloaded entries become idle immediately and follow the idle TTL.
361
+ * The default idle TTL is zero, so preloading only occurs when a nonzero
362
+ * `idleTimeToLive` is configured.
363
+ */
340
364
  readonly preload?: boolean
341
365
  }, Options>
342
366
  >(
@@ -1719,12 +1719,14 @@ export const addFinalizer = <X, R>(
1719
1719
  core.withFiberRuntime((runtimeFinalizer) => {
1720
1720
  const preRefs = runtimeFinalizer.getFiberRefs()
1721
1721
  const preFlags = runtimeFinalizer.currentRuntimeFlags
1722
+ const interruptedCause = runtimeFinalizer.getFiberRef(core.currentInterruptedCause)
1722
1723
  const patchRefs = FiberRefsPatch.diff(preRefs, acquireRefs)
1723
1724
  const patchFlags = runtimeFlags_.diff(preFlags, acquireFlags)
1724
1725
  const inverseRefs = FiberRefsPatch.diff(acquireRefs, preRefs)
1725
1726
  runtimeFinalizer.setFiberRefs(
1726
1727
  FiberRefsPatch.patch(patchRefs, runtimeFinalizer.id(), acquireRefs)
1727
1728
  )
1729
+ runtimeFinalizer.setFiberRef(core.currentInterruptedCause, interruptedCause)
1728
1730
 
1729
1731
  return ensuring(
1730
1732
  core.withRuntimeFlags(finalizer(exit) as Effect.Effect<X>, patchFlags),
@@ -43,6 +43,7 @@ export const auto = <I, S, E, In, R>(
43
43
  reloadable.reload,
44
44
  effect.ignoreLogged,
45
45
  schedule_.schedule_Effect(options.schedule),
46
+ core.interruptible,
46
47
  fiberRuntime.forkDaemon
47
48
  ),
48
49
  core.interruptFiber
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.22.2"
1
+ let moduleVersion = "3.22.3"
2
2
 
3
3
  export const getCurrentVersion = () => moduleVersion
4
4