effect 3.22.2 → 3.22.4
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/dist/cjs/BigDecimal.js +4 -3
- package/dist/cjs/BigDecimal.js.map +1 -1
- package/dist/cjs/Duration.js +10 -3
- package/dist/cjs/Duration.js.map +1 -1
- package/dist/cjs/Effect.js +49 -35
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/LayerMap.js +7 -5
- package/dist/cjs/LayerMap.js.map +1 -1
- package/dist/cjs/Micro.js +4 -3
- package/dist/cjs/Micro.js.map +1 -1
- package/dist/cjs/Stream.js +1 -1
- package/dist/cjs/internal/cause.js +6 -5
- package/dist/cjs/internal/cause.js.map +1 -1
- package/dist/cjs/internal/context.js +10 -9
- package/dist/cjs/internal/context.js.map +1 -1
- package/dist/cjs/internal/core-effect.js +4 -3
- package/dist/cjs/internal/core-effect.js.map +1 -1
- package/dist/cjs/internal/effect/circular.js +2 -2
- package/dist/cjs/internal/effect/circular.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +2 -0
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/layer.js +4 -3
- package/dist/cjs/internal/layer.js.map +1 -1
- package/dist/cjs/internal/logger.js +11 -2
- package/dist/cjs/internal/logger.js.map +1 -1
- package/dist/cjs/internal/reloadable.js +1 -1
- package/dist/cjs/internal/reloadable.js.map +1 -1
- package/dist/cjs/internal/runtime.js +14 -8
- package/dist/cjs/internal/runtime.js.map +1 -1
- package/dist/cjs/internal/stackTraceLimit.js +49 -0
- package/dist/cjs/internal/stackTraceLimit.js.map +1 -0
- package/dist/cjs/internal/tracer.js +4 -3
- package/dist/cjs/internal/tracer.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Duration.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +48 -43
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/LayerMap.d.ts +21 -1
- package/dist/dts/LayerMap.d.ts.map +1 -1
- package/dist/dts/Micro.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts +1 -1
- package/dist/dts/internal/context.d.ts.map +1 -1
- package/dist/dts/internal/core-effect.d.ts.map +1 -1
- package/dist/dts/internal/layer.d.ts.map +1 -1
- package/dist/dts/internal/stackTraceLimit.d.ts +2 -0
- package/dist/dts/internal/stackTraceLimit.d.ts.map +1 -0
- package/dist/esm/BigDecimal.js +4 -3
- package/dist/esm/BigDecimal.js.map +1 -1
- package/dist/esm/Duration.js +10 -3
- package/dist/esm/Duration.js.map +1 -1
- package/dist/esm/Effect.js +49 -35
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/LayerMap.js +7 -5
- package/dist/esm/LayerMap.js.map +1 -1
- package/dist/esm/Micro.js +4 -3
- package/dist/esm/Micro.js.map +1 -1
- package/dist/esm/Stream.js +1 -1
- package/dist/esm/internal/cause.js +6 -5
- package/dist/esm/internal/cause.js.map +1 -1
- package/dist/esm/internal/context.js +10 -9
- package/dist/esm/internal/context.js.map +1 -1
- package/dist/esm/internal/core-effect.js +4 -3
- package/dist/esm/internal/core-effect.js.map +1 -1
- package/dist/esm/internal/effect/circular.js +2 -2
- package/dist/esm/internal/effect/circular.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +2 -0
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/layer.js +4 -3
- package/dist/esm/internal/layer.js.map +1 -1
- package/dist/esm/internal/logger.js +10 -1
- package/dist/esm/internal/logger.js.map +1 -1
- package/dist/esm/internal/reloadable.js +1 -1
- package/dist/esm/internal/reloadable.js.map +1 -1
- package/dist/esm/internal/runtime.js +14 -8
- package/dist/esm/internal/runtime.js.map +1 -1
- package/dist/esm/internal/stackTraceLimit.js +40 -0
- package/dist/esm/internal/stackTraceLimit.js.map +1 -0
- package/dist/esm/internal/tracer.js +4 -3
- package/dist/esm/internal/tracer.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/BigDecimal.ts +4 -4
- package/src/Duration.ts +12 -3
- package/src/Effect.ts +78 -59
- package/src/LayerMap.ts +31 -6
- package/src/Micro.ts +4 -3
- package/src/Stream.ts +1 -1
- package/src/internal/cause.ts +6 -5
- package/src/internal/context.ts +10 -9
- package/src/internal/core-effect.ts +4 -3
- package/src/internal/effect/circular.ts +22 -24
- package/src/internal/fiberRuntime.ts +2 -0
- package/src/internal/layer.ts +4 -3
- package/src/internal/logger.ts +9 -1
- package/src/internal/reloadable.ts +1 -0
- package/src/internal/runtime.ts +14 -8
- package/src/internal/stackTraceLimit.ts +65 -0
- package/src/internal/tracer.ts +4 -3
- package/src/internal/version.ts +1 -1
package/src/Duration.ts
CHANGED
|
@@ -88,6 +88,9 @@ export type DurationInput =
|
|
|
88
88
|
|
|
89
89
|
const DURATION_REGEX = /^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/
|
|
90
90
|
|
|
91
|
+
const parseNanos = (input: string, scale: number): bigint =>
|
|
92
|
+
input.includes(".") ? BigInt(Math.round(Number(input) * scale)) : BigInt(input) * BigInt(scale)
|
|
93
|
+
|
|
91
94
|
/**
|
|
92
95
|
* @since 2.0.0
|
|
93
96
|
*/
|
|
@@ -116,10 +119,10 @@ export const decode = (input: DurationInput): Duration => {
|
|
|
116
119
|
switch (unit) {
|
|
117
120
|
case "nano":
|
|
118
121
|
case "nanos":
|
|
119
|
-
return nanos(
|
|
122
|
+
return nanos(parseNanos(valueStr, 1))
|
|
120
123
|
case "micro":
|
|
121
124
|
case "micros":
|
|
122
|
-
return
|
|
125
|
+
return nanos(parseNanos(valueStr, 1_000))
|
|
123
126
|
case "milli":
|
|
124
127
|
case "millis":
|
|
125
128
|
return millis(value)
|
|
@@ -735,7 +738,13 @@ export const times: {
|
|
|
735
738
|
(self: DurationInput, times: number): Duration =>
|
|
736
739
|
match(self, {
|
|
737
740
|
onMillis: (millis) => make(millis * times),
|
|
738
|
-
onNanos: (nanos) =>
|
|
741
|
+
onNanos: (nanos) => {
|
|
742
|
+
if (Number.isInteger(times)) {
|
|
743
|
+
return make(nanos * BigInt(times))
|
|
744
|
+
}
|
|
745
|
+
const result = Number(nanos) * times
|
|
746
|
+
return make(Number.isFinite(result) ? BigInt(Math.round(result)) : result)
|
|
747
|
+
}
|
|
739
748
|
})
|
|
740
749
|
)
|
|
741
750
|
|
package/src/Effect.ts
CHANGED
|
@@ -40,6 +40,7 @@ import * as option_ from "./internal/option.js"
|
|
|
40
40
|
import * as query from "./internal/query.js"
|
|
41
41
|
import * as runtime_ from "./internal/runtime.js"
|
|
42
42
|
import * as schedule_ from "./internal/schedule.js"
|
|
43
|
+
import { getStackTraceLimit, setStackTraceLimit } from "./internal/stackTraceLimit.js"
|
|
43
44
|
import * as internalTracer from "./internal/tracer.js"
|
|
44
45
|
import type * as Layer from "./Layer.js"
|
|
45
46
|
import type * as LogLevel from "./LogLevel.js"
|
|
@@ -1023,7 +1024,7 @@ export const once: <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<void, E, R>
|
|
|
1023
1024
|
* // {
|
|
1024
1025
|
* // _id: 'Exit',
|
|
1025
1026
|
* // _tag: 'Failure',
|
|
1026
|
-
* // cause: { _id: 'Cause', _tag: 'Fail',
|
|
1027
|
+
* // cause: { _id: 'Cause', _tag: 'Fail', error: 'Task2: Oh no!' }
|
|
1027
1028
|
* // }
|
|
1028
1029
|
* ```
|
|
1029
1030
|
*
|
|
@@ -1078,7 +1079,7 @@ export const once: <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<void, E, R>
|
|
|
1078
1079
|
* // cause: {
|
|
1079
1080
|
* // _id: 'Cause',
|
|
1080
1081
|
* // _tag: 'Fail',
|
|
1081
|
-
* //
|
|
1082
|
+
* // error: [
|
|
1082
1083
|
* // { _id: 'Option', _tag: 'None' },
|
|
1083
1084
|
* // { _id: 'Option', _tag: 'Some', value: 'Task2: Oh no!' },
|
|
1084
1085
|
* // { _id: 'Option', _tag: 'None' }
|
|
@@ -4399,7 +4400,7 @@ export const replicateEffect: {
|
|
|
4399
4400
|
* // cause: {
|
|
4400
4401
|
* // _id: 'Cause',
|
|
4401
4402
|
* // _tag: 'Fail',
|
|
4402
|
-
* //
|
|
4403
|
+
* // error: [ '4 is not less that 4', '5 is not less that 4' ]
|
|
4403
4404
|
* // }
|
|
4404
4405
|
* // }
|
|
4405
4406
|
* ```
|
|
@@ -4460,7 +4461,7 @@ export const validateAll: {
|
|
|
4460
4461
|
* // cause: {
|
|
4461
4462
|
* // _id: 'Cause',
|
|
4462
4463
|
* // _tag: 'Fail',
|
|
4463
|
-
* //
|
|
4464
|
+
* // error: [ '4 is not less that 4', '5 is not less that 4' ]
|
|
4464
4465
|
* // }
|
|
4465
4466
|
* // }
|
|
4466
4467
|
* ```
|
|
@@ -4529,7 +4530,7 @@ export const validateAll: {
|
|
|
4529
4530
|
* // cause: {
|
|
4530
4531
|
* // _id: 'Cause',
|
|
4531
4532
|
* // _tag: 'Fail',
|
|
4532
|
-
* //
|
|
4533
|
+
* // error: [ '4 is not less that 4', '5 is not less that 4' ]
|
|
4533
4534
|
* // }
|
|
4534
4535
|
* // }
|
|
4535
4536
|
* ```
|
|
@@ -4598,7 +4599,7 @@ export const validateAll: {
|
|
|
4598
4599
|
* // cause: {
|
|
4599
4600
|
* // _id: 'Cause',
|
|
4600
4601
|
* // _tag: 'Fail',
|
|
4601
|
-
* //
|
|
4602
|
+
* // error: [ '4 is not less that 4', '5 is not less that 4' ]
|
|
4602
4603
|
* // }
|
|
4603
4604
|
* // }
|
|
4604
4605
|
* ```
|
|
@@ -4668,7 +4669,7 @@ export const validateAll: {
|
|
|
4668
4669
|
* // cause: {
|
|
4669
4670
|
* // _id: 'Cause',
|
|
4670
4671
|
* // _tag: 'Fail',
|
|
4671
|
-
* //
|
|
4672
|
+
* // error: [ '4 is not less that 4', '5 is not less that 4' ]
|
|
4672
4673
|
* // }
|
|
4673
4674
|
* // }
|
|
4674
4675
|
* ```
|
|
@@ -7779,7 +7780,7 @@ export const ignoreLogged: <A, E, R>(self: Effect<A, E, R>) => Effect<void, neve
|
|
|
7779
7780
|
* // {
|
|
7780
7781
|
* // _id: 'Exit',
|
|
7781
7782
|
* // _tag: 'Failure',
|
|
7782
|
-
* // cause: { _id: 'Cause', _tag: 'Fail',
|
|
7783
|
+
* // cause: { _id: 'Cause', _tag: 'Fail', error: [ 'Oh uh!', 'Oh no!' ] }
|
|
7783
7784
|
* // }
|
|
7784
7785
|
* ```
|
|
7785
7786
|
*
|
|
@@ -7993,7 +7994,7 @@ export declare namespace Retry {
|
|
|
7993
7994
|
* // {
|
|
7994
7995
|
* // _id: 'Exit',
|
|
7995
7996
|
* // _tag: 'Failure',
|
|
7996
|
-
* // cause: { _id: 'Cause', _tag: 'Fail',
|
|
7997
|
+
* // cause: { _id: 'Cause', _tag: 'Fail', error: 'Error 3' }
|
|
7997
7998
|
* // }
|
|
7998
7999
|
* ```
|
|
7999
8000
|
*
|
|
@@ -8112,7 +8113,7 @@ export const retry: {
|
|
|
8112
8113
|
* // {
|
|
8113
8114
|
* // _id: 'Exit',
|
|
8114
8115
|
* // _tag: 'Failure',
|
|
8115
|
-
* // cause: { _id: 'Cause', _tag: 'Fail',
|
|
8116
|
+
* // cause: { _id: 'Cause', _tag: 'Fail', error: 'Error 3' }
|
|
8116
8117
|
* // }
|
|
8117
8118
|
* ```
|
|
8118
8119
|
*
|
|
@@ -8231,7 +8232,7 @@ export const retry: {
|
|
|
8231
8232
|
* // {
|
|
8232
8233
|
* // _id: 'Exit',
|
|
8233
8234
|
* // _tag: 'Failure',
|
|
8234
|
-
* // cause: { _id: 'Cause', _tag: 'Fail',
|
|
8235
|
+
* // cause: { _id: 'Cause', _tag: 'Fail', error: 'Error 3' }
|
|
8235
8236
|
* // }
|
|
8236
8237
|
* ```
|
|
8237
8238
|
*
|
|
@@ -8350,7 +8351,7 @@ export const retry: {
|
|
|
8350
8351
|
* // {
|
|
8351
8352
|
* // _id: 'Exit',
|
|
8352
8353
|
* // _tag: 'Failure',
|
|
8353
|
-
* // cause: { _id: 'Cause', _tag: 'Fail',
|
|
8354
|
+
* // cause: { _id: 'Cause', _tag: 'Fail', error: 'Error 3' }
|
|
8354
8355
|
* // }
|
|
8355
8356
|
* ```
|
|
8356
8357
|
*
|
|
@@ -8469,7 +8470,7 @@ export const retry: {
|
|
|
8469
8470
|
* // {
|
|
8470
8471
|
* // _id: 'Exit',
|
|
8471
8472
|
* // _tag: 'Failure',
|
|
8472
|
-
* // cause: { _id: 'Cause', _tag: 'Fail',
|
|
8473
|
+
* // cause: { _id: 'Cause', _tag: 'Fail', error: 'Error 3' }
|
|
8473
8474
|
* // }
|
|
8474
8475
|
* ```
|
|
8475
8476
|
*
|
|
@@ -9204,7 +9205,7 @@ export const checkInterruptible: <A, E, R>(f: (isInterruptible: boolean) => Effe
|
|
|
9204
9205
|
* // cause: {
|
|
9205
9206
|
* // _id: 'Cause',
|
|
9206
9207
|
* // _tag: 'Fail',
|
|
9207
|
-
* //
|
|
9208
|
+
* // error: { _tag: 'TimeoutException' }
|
|
9208
9209
|
* // }
|
|
9209
9210
|
* // }
|
|
9210
9211
|
* // Heavy processing done.
|
|
@@ -10859,7 +10860,7 @@ export const acquireUseRelease: {
|
|
|
10859
10860
|
* // {
|
|
10860
10861
|
* // _id: 'Exit',
|
|
10861
10862
|
* // _tag: 'Failure',
|
|
10862
|
-
* // cause: { _id: 'Cause', _tag: 'Fail',
|
|
10863
|
+
* // cause: { _id: 'Cause', _tag: 'Fail', error: 'Uh oh!' }
|
|
10863
10864
|
* // }
|
|
10864
10865
|
* ```
|
|
10865
10866
|
*
|
|
@@ -13300,7 +13301,7 @@ export const timedWith: {
|
|
|
13300
13301
|
* // cause: {
|
|
13301
13302
|
* // _id: 'Cause',
|
|
13302
13303
|
* // _tag: 'Fail',
|
|
13303
|
-
* //
|
|
13304
|
+
* // error: { _tag: 'TimeoutException' }
|
|
13304
13305
|
* // }
|
|
13305
13306
|
* // }
|
|
13306
13307
|
* ```
|
|
@@ -13356,7 +13357,7 @@ export const timeout: {
|
|
|
13356
13357
|
* // cause: {
|
|
13357
13358
|
* // _id: 'Cause',
|
|
13358
13359
|
* // _tag: 'Fail',
|
|
13359
|
-
* //
|
|
13360
|
+
* // error: { _tag: 'TimeoutException' }
|
|
13360
13361
|
* // }
|
|
13361
13362
|
* // }
|
|
13362
13363
|
* ```
|
|
@@ -13412,7 +13413,7 @@ export const timeout: {
|
|
|
13412
13413
|
* // cause: {
|
|
13413
13414
|
* // _id: 'Cause',
|
|
13414
13415
|
* // _tag: 'Fail',
|
|
13415
|
-
* //
|
|
13416
|
+
* // error: { _tag: 'TimeoutException' }
|
|
13416
13417
|
* // }
|
|
13417
13418
|
* // }
|
|
13418
13419
|
* ```
|
|
@@ -13653,7 +13654,7 @@ export const timeoutOption: {
|
|
|
13653
13654
|
* // cause: {
|
|
13654
13655
|
* // _id: 'Cause',
|
|
13655
13656
|
* // _tag: 'Fail',
|
|
13656
|
-
* //
|
|
13657
|
+
* // error: MyTimeoutError { _tag: 'MyTimeoutError' }
|
|
13657
13658
|
* // }
|
|
13658
13659
|
* // }
|
|
13659
13660
|
* ```
|
|
@@ -13719,7 +13720,7 @@ export const timeoutFail: {
|
|
|
13719
13720
|
* // cause: {
|
|
13720
13721
|
* // _id: 'Cause',
|
|
13721
13722
|
* // _tag: 'Fail',
|
|
13722
|
-
* //
|
|
13723
|
+
* // error: MyTimeoutError { _tag: 'MyTimeoutError' }
|
|
13723
13724
|
* // }
|
|
13724
13725
|
* // }
|
|
13725
13726
|
* ```
|
|
@@ -13787,7 +13788,7 @@ export const timeoutFail: {
|
|
|
13787
13788
|
* // cause: {
|
|
13788
13789
|
* // _id: 'Cause',
|
|
13789
13790
|
* // _tag: 'Fail',
|
|
13790
|
-
* //
|
|
13791
|
+
* // error: MyTimeoutError { _tag: 'MyTimeoutError' }
|
|
13791
13792
|
* // }
|
|
13792
13793
|
* // }
|
|
13793
13794
|
* ```
|
|
@@ -18473,8 +18474,8 @@ export const flatten: <A, E1, R1, E, R>(self: Effect<Effect<A, E1, R1>, E, R>) =
|
|
|
18473
18474
|
* // cause: {
|
|
18474
18475
|
* // _id: 'Cause',
|
|
18475
18476
|
* // _tag: 'Parallel',
|
|
18476
|
-
* // left: { _id: 'Cause', _tag: 'Fail',
|
|
18477
|
-
* // right: { _id: 'Cause', _tag: 'Fail',
|
|
18477
|
+
* // left: { _id: 'Cause', _tag: 'Fail', error: 'task1' },
|
|
18478
|
+
* // right: { _id: 'Cause', _tag: 'Fail', error: 'task2' }
|
|
18478
18479
|
* // }
|
|
18479
18480
|
* // }
|
|
18480
18481
|
* ```
|
|
@@ -18611,8 +18612,8 @@ export const race: {
|
|
|
18611
18612
|
* // cause: {
|
|
18612
18613
|
* // _id: 'Cause',
|
|
18613
18614
|
* // _tag: 'Parallel',
|
|
18614
|
-
* // left: { _id: 'Cause', _tag: 'Fail',
|
|
18615
|
-
* // right: { _id: 'Cause', _tag: 'Fail',
|
|
18615
|
+
* // left: { _id: 'Cause', _tag: 'Fail', error: 'task1' },
|
|
18616
|
+
* // right: { _id: 'Cause', _tag: 'Fail', error: 'task2' }
|
|
18616
18617
|
* // }
|
|
18617
18618
|
* // }
|
|
18618
18619
|
* ```
|
|
@@ -18749,8 +18750,8 @@ export const race: {
|
|
|
18749
18750
|
* // cause: {
|
|
18750
18751
|
* // _id: 'Cause',
|
|
18751
18752
|
* // _tag: 'Parallel',
|
|
18752
|
-
* // left: { _id: 'Cause', _tag: 'Fail',
|
|
18753
|
-
* // right: { _id: 'Cause', _tag: 'Fail',
|
|
18753
|
+
* // left: { _id: 'Cause', _tag: 'Fail', error: 'task1' },
|
|
18754
|
+
* // right: { _id: 'Cause', _tag: 'Fail', error: 'task2' }
|
|
18754
18755
|
* // }
|
|
18755
18756
|
* // }
|
|
18756
18757
|
* ```
|
|
@@ -18899,7 +18900,7 @@ export const race: {
|
|
|
18899
18900
|
* // {
|
|
18900
18901
|
* // _id: 'Exit',
|
|
18901
18902
|
* // _tag: 'Failure',
|
|
18902
|
-
* // cause: { _id: 'Cause', _tag: 'Fail',
|
|
18903
|
+
* // cause: { _id: 'Cause', _tag: 'Fail', error: 'task2' }
|
|
18903
18904
|
* // }
|
|
18904
18905
|
* ```
|
|
18905
18906
|
*
|
|
@@ -19007,7 +19008,7 @@ export const raceAll: <Eff extends Effect<any, any, any>>(
|
|
|
19007
19008
|
* // {
|
|
19008
19009
|
* // _id: 'Exit',
|
|
19009
19010
|
* // _tag: 'Failure',
|
|
19010
|
-
* // cause: { _id: 'Cause', _tag: 'Fail',
|
|
19011
|
+
* // cause: { _id: 'Cause', _tag: 'Fail', error: 'task1' }
|
|
19011
19012
|
* // }
|
|
19012
19013
|
* ```
|
|
19013
19014
|
*
|
|
@@ -19144,7 +19145,7 @@ export const raceFirst: {
|
|
|
19144
19145
|
* // {
|
|
19145
19146
|
* // _id: 'Exit',
|
|
19146
19147
|
* // _tag: 'Failure',
|
|
19147
|
-
* // cause: { _id: 'Cause', _tag: 'Fail',
|
|
19148
|
+
* // cause: { _id: 'Cause', _tag: 'Fail', error: 'task1' }
|
|
19148
19149
|
* // }
|
|
19149
19150
|
* ```
|
|
19150
19151
|
*
|
|
@@ -19281,7 +19282,7 @@ export const raceFirst: {
|
|
|
19281
19282
|
* // {
|
|
19282
19283
|
* // _id: 'Exit',
|
|
19283
19284
|
* // _tag: 'Failure',
|
|
19284
|
-
* // cause: { _id: 'Cause', _tag: 'Fail',
|
|
19285
|
+
* // cause: { _id: 'Cause', _tag: 'Fail', error: 'task1' }
|
|
19285
19286
|
* // }
|
|
19286
19287
|
* ```
|
|
19287
19288
|
*
|
|
@@ -24425,7 +24426,7 @@ export const orElse: {
|
|
|
24425
24426
|
* // {
|
|
24426
24427
|
* // _id: 'Exit',
|
|
24427
24428
|
* // _tag: 'Failure',
|
|
24428
|
-
* // cause: { _id: 'Cause', _tag: 'Fail',
|
|
24429
|
+
* // cause: { _id: 'Cause', _tag: 'Fail', error: 'invalid age' }
|
|
24429
24430
|
* // }
|
|
24430
24431
|
* ```
|
|
24431
24432
|
*
|
|
@@ -24475,7 +24476,7 @@ export const orElseFail: {
|
|
|
24475
24476
|
* // {
|
|
24476
24477
|
* // _id: 'Exit',
|
|
24477
24478
|
* // _tag: 'Failure',
|
|
24478
|
-
* // cause: { _id: 'Cause', _tag: 'Fail',
|
|
24479
|
+
* // cause: { _id: 'Cause', _tag: 'Fail', error: 'invalid age' }
|
|
24479
24480
|
* // }
|
|
24480
24481
|
* ```
|
|
24481
24482
|
*
|
|
@@ -24525,7 +24526,7 @@ export const orElseFail: {
|
|
|
24525
24526
|
* // {
|
|
24526
24527
|
* // _id: 'Exit',
|
|
24527
24528
|
* // _tag: 'Failure',
|
|
24528
|
-
* // cause: { _id: 'Cause', _tag: 'Fail',
|
|
24529
|
+
* // cause: { _id: 'Cause', _tag: 'Fail', error: 'invalid age' }
|
|
24529
24530
|
* // }
|
|
24530
24531
|
* ```
|
|
24531
24532
|
*
|
|
@@ -25183,6 +25184,11 @@ export interface Semaphore {
|
|
|
25183
25184
|
|
|
25184
25185
|
/**
|
|
25185
25186
|
* Releases all permits held by this semaphore and returns the resulting available permits.
|
|
25187
|
+
*
|
|
25188
|
+
* This does not stop effects already running with `withPermits` or
|
|
25189
|
+
* `withPermitsIfAvailable`. Their permits become available immediately, but
|
|
25190
|
+
* those effects still release their permits when they finish. The resulting
|
|
25191
|
+
* available count can exceed the semaphore's capacity.
|
|
25186
25192
|
*/
|
|
25187
25193
|
releaseAll: Effect<number>
|
|
25188
25194
|
}
|
|
@@ -25553,7 +25559,7 @@ export const runPromise: <A, E>(
|
|
|
25553
25559
|
* // cause: {
|
|
25554
25560
|
* // _id: "Cause",
|
|
25555
25561
|
* // _tag: "Fail",
|
|
25556
|
-
* //
|
|
25562
|
+
* // error: "my error"
|
|
25557
25563
|
* // }
|
|
25558
25564
|
* // }
|
|
25559
25565
|
* ```
|
|
@@ -25691,7 +25697,7 @@ export const runSync: <A, E>(effect: Effect<A, E>) => A = runtime_.unsafeRunSync
|
|
|
25691
25697
|
* // cause: {
|
|
25692
25698
|
* // _id: "Cause",
|
|
25693
25699
|
* // _tag: "Fail",
|
|
25694
|
-
* //
|
|
25700
|
+
* // error: "my error"
|
|
25695
25701
|
* // }
|
|
25696
25702
|
* // }
|
|
25697
25703
|
* ```
|
|
@@ -25764,8 +25770,8 @@ export const runSyncExit: <A, E>(effect: Effect<A, E>) => Exit.Exit<A, E> = runt
|
|
|
25764
25770
|
* // cause: {
|
|
25765
25771
|
* // _id: 'Cause',
|
|
25766
25772
|
* // _tag: 'Sequential',
|
|
25767
|
-
* // left: { _id: 'Cause', _tag: 'Fail',
|
|
25768
|
-
* // right: { _id: 'Cause', _tag: 'Fail',
|
|
25773
|
+
* // left: { _id: 'Cause', _tag: 'Fail', error: 'Oh uh!' },
|
|
25774
|
+
* // right: { _id: 'Cause', _tag: 'Fail', error: 'Oh no!' }
|
|
25769
25775
|
* // }
|
|
25770
25776
|
* // }
|
|
25771
25777
|
* ```
|
|
@@ -25817,8 +25823,8 @@ export const validate: {
|
|
|
25817
25823
|
* // cause: {
|
|
25818
25824
|
* // _id: 'Cause',
|
|
25819
25825
|
* // _tag: 'Sequential',
|
|
25820
|
-
* // left: { _id: 'Cause', _tag: 'Fail',
|
|
25821
|
-
* // right: { _id: 'Cause', _tag: 'Fail',
|
|
25826
|
+
* // left: { _id: 'Cause', _tag: 'Fail', error: 'Oh uh!' },
|
|
25827
|
+
* // right: { _id: 'Cause', _tag: 'Fail', error: 'Oh no!' }
|
|
25822
25828
|
* // }
|
|
25823
25829
|
* // }
|
|
25824
25830
|
* ```
|
|
@@ -25877,8 +25883,8 @@ export const validate: {
|
|
|
25877
25883
|
* // cause: {
|
|
25878
25884
|
* // _id: 'Cause',
|
|
25879
25885
|
* // _tag: 'Sequential',
|
|
25880
|
-
* // left: { _id: 'Cause', _tag: 'Fail',
|
|
25881
|
-
* // right: { _id: 'Cause', _tag: 'Fail',
|
|
25886
|
+
* // left: { _id: 'Cause', _tag: 'Fail', error: 'Oh uh!' },
|
|
25887
|
+
* // right: { _id: 'Cause', _tag: 'Fail', error: 'Oh no!' }
|
|
25882
25888
|
* // }
|
|
25883
25889
|
* // }
|
|
25884
25890
|
* ```
|
|
@@ -27461,7 +27467,7 @@ export const withParentSpan: {
|
|
|
27461
27467
|
* // cause: {
|
|
27462
27468
|
* // _id: 'Cause',
|
|
27463
27469
|
* // _tag: 'Fail',
|
|
27464
|
-
* //
|
|
27470
|
+
* // error: { _tag: 'NoSuchElementException' }
|
|
27465
27471
|
* // }
|
|
27466
27472
|
* // }
|
|
27467
27473
|
* ```
|
|
@@ -27802,10 +27808,10 @@ export const Tag: <const Id extends string>(id: Id) => <
|
|
|
27802
27808
|
: [X] extends [PromiseLike<infer A>] ? Effect<A, Cause.UnknownException, Self>
|
|
27803
27809
|
: Effect<X, never, Self>
|
|
27804
27810
|
} = (id) => () => {
|
|
27805
|
-
const limit =
|
|
27806
|
-
|
|
27811
|
+
const limit = getStackTraceLimit()
|
|
27812
|
+
setStackTraceLimit(2)
|
|
27807
27813
|
const creationError = new Error()
|
|
27808
|
-
|
|
27814
|
+
setStackTraceLimit(limit)
|
|
27809
27815
|
function TagClass() {}
|
|
27810
27816
|
Object.setPrototypeOf(TagClass, TagProto)
|
|
27811
27817
|
TagClass.key = id
|
|
@@ -27961,10 +27967,10 @@ export const Service: <Self = never>() => [Self] extends [never] ? MissingSelfGe
|
|
|
27961
27967
|
return function() {
|
|
27962
27968
|
const [id, maker] = arguments
|
|
27963
27969
|
const proxy = "accessors" in maker ? maker["accessors"] : false
|
|
27964
|
-
const limit =
|
|
27965
|
-
|
|
27970
|
+
const limit = getStackTraceLimit()
|
|
27971
|
+
setStackTraceLimit(2)
|
|
27966
27972
|
const creationError = new Error()
|
|
27967
|
-
|
|
27973
|
+
setStackTraceLimit(limit)
|
|
27968
27974
|
|
|
27969
27975
|
let patchState: "unchecked" | "plain" | "patched" = "unchecked"
|
|
27970
27976
|
const TagClass: any = function(this: any, service: any) {
|
|
@@ -28921,16 +28927,16 @@ export const fn:
|
|
|
28921
28927
|
name: string,
|
|
28922
28928
|
options?: Tracer.SpanOptions
|
|
28923
28929
|
) => fn.Gen & fn.NonGen) = function(nameOrBody: Function | string, ...pipeables: Array<any>) {
|
|
28924
|
-
const limit =
|
|
28925
|
-
|
|
28930
|
+
const limit = getStackTraceLimit()
|
|
28931
|
+
setStackTraceLimit(2)
|
|
28926
28932
|
const errorDef = new Error()
|
|
28927
|
-
|
|
28933
|
+
setStackTraceLimit(limit)
|
|
28928
28934
|
if (typeof nameOrBody !== "string") {
|
|
28929
28935
|
return defineLength(nameOrBody.length, function(this: any, ...args: Array<any>) {
|
|
28930
|
-
const limit =
|
|
28931
|
-
|
|
28936
|
+
const limit = getStackTraceLimit()
|
|
28937
|
+
setStackTraceLimit(2)
|
|
28932
28938
|
const errorCall = new Error()
|
|
28933
|
-
|
|
28939
|
+
setStackTraceLimit(limit)
|
|
28934
28940
|
return fnApply({
|
|
28935
28941
|
self: this,
|
|
28936
28942
|
body: nameOrBody,
|
|
@@ -28952,10 +28958,10 @@ export const fn:
|
|
|
28952
28958
|
body.length,
|
|
28953
28959
|
({
|
|
28954
28960
|
[name](this: any, ...args: Array<any>) {
|
|
28955
|
-
const limit =
|
|
28956
|
-
|
|
28961
|
+
const limit = getStackTraceLimit()
|
|
28962
|
+
setStackTraceLimit(2)
|
|
28957
28963
|
const errorCall = new Error()
|
|
28958
|
-
|
|
28964
|
+
setStackTraceLimit(limit)
|
|
28959
28965
|
return fnApply({
|
|
28960
28966
|
self: this,
|
|
28961
28967
|
body,
|
|
@@ -28994,7 +29000,20 @@ function fnApply(options: {
|
|
|
28994
29000
|
effect = core.fromIterator(() => options.body.apply(options.self, options.args))
|
|
28995
29001
|
} else {
|
|
28996
29002
|
try {
|
|
28997
|
-
|
|
29003
|
+
const result = options.body.apply(options.self, options.args)
|
|
29004
|
+
if (core.isEffect(result)) {
|
|
29005
|
+
effect = result
|
|
29006
|
+
} else {
|
|
29007
|
+
// transpiled generator bodies return an iterator; reuse it for the first run
|
|
29008
|
+
let first = true
|
|
29009
|
+
effect = core.fromIterator(() => {
|
|
29010
|
+
if (first) {
|
|
29011
|
+
first = false
|
|
29012
|
+
return result
|
|
29013
|
+
}
|
|
29014
|
+
return options.body.apply(options.self, options.args)
|
|
29015
|
+
})
|
|
29016
|
+
}
|
|
28998
29017
|
} catch (error) {
|
|
28999
29018
|
fnError = error
|
|
29000
29019
|
effect = die(error)
|
package/src/LayerMap.ts
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
* @experimental
|
|
4
4
|
*/
|
|
5
5
|
import * as Context from "./Context.js"
|
|
6
|
-
import
|
|
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"
|
|
10
10
|
import * as core from "./internal/core.js"
|
|
11
|
+
import { getStackTraceLimit, setStackTraceLimit } from "./internal/stackTraceLimit.js"
|
|
11
12
|
import * as Layer from "./Layer.js"
|
|
12
13
|
import * as RcMap from "./RcMap.js"
|
|
13
14
|
import * as Runtime from "./Runtime.js"
|
|
@@ -119,6 +120,11 @@ export const make: <
|
|
|
119
120
|
lookup: (key: K) => L,
|
|
120
121
|
options?: {
|
|
121
122
|
readonly idleTimeToLive?: Duration.DurationInput | undefined
|
|
123
|
+
/**
|
|
124
|
+
* Preloaded entries become idle immediately and follow the idle TTL.
|
|
125
|
+
* The default idle TTL is zero, so preloading only occurs when a nonzero
|
|
126
|
+
* `idleTimeToLive` is configured.
|
|
127
|
+
*/
|
|
122
128
|
readonly preloadKeys?: PreloadKeys
|
|
123
129
|
} | undefined
|
|
124
130
|
) => Effect.Effect<
|
|
@@ -177,9 +183,13 @@ export const make: <
|
|
|
177
183
|
idleTimeToLive: options?.idleTimeToLive
|
|
178
184
|
})
|
|
179
185
|
|
|
180
|
-
if (
|
|
186
|
+
if (
|
|
187
|
+
options?.preloadKeys &&
|
|
188
|
+
options.idleTimeToLive !== undefined &&
|
|
189
|
+
!Duration.isZero(Duration.decode(options.idleTimeToLive))
|
|
190
|
+
) {
|
|
181
191
|
for (const key of options.preloadKeys) {
|
|
182
|
-
yield* (RcMap.get(rcMap, key) as Effect.Effect<any, EL, RL | Scope.Scope>)
|
|
192
|
+
yield* Effect.scoped(RcMap.get(rcMap, key) as Effect.Effect<any, EL, RL | Scope.Scope>)
|
|
183
193
|
}
|
|
184
194
|
}
|
|
185
195
|
|
|
@@ -204,6 +214,11 @@ export const fromRecord = <
|
|
|
204
214
|
layers: Layers,
|
|
205
215
|
options?: {
|
|
206
216
|
readonly idleTimeToLive?: Duration.DurationInput | undefined
|
|
217
|
+
/**
|
|
218
|
+
* Preloaded entries become idle immediately and follow the idle TTL.
|
|
219
|
+
* The default idle TTL is zero, so preloading only occurs when a nonzero
|
|
220
|
+
* `idleTimeToLive` is configured.
|
|
221
|
+
*/
|
|
207
222
|
readonly preload?: Preload | undefined
|
|
208
223
|
} | undefined
|
|
209
224
|
): Effect.Effect<
|
|
@@ -327,6 +342,11 @@ export const Service = <Self>() =>
|
|
|
327
342
|
readonly lookup: (key: any) => Layer.Layer<any, any, any>
|
|
328
343
|
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>>
|
|
329
344
|
readonly idleTimeToLive?: Duration.DurationInput | undefined
|
|
345
|
+
/**
|
|
346
|
+
* Preloaded entries become idle immediately and follow the idle TTL.
|
|
347
|
+
* The default idle TTL is zero, so preloading only occurs when a nonzero
|
|
348
|
+
* `idleTimeToLive` is configured.
|
|
349
|
+
*/
|
|
330
350
|
readonly preloadKeys?:
|
|
331
351
|
| Iterable<Options extends { readonly lookup: (key: infer K) => any } ? K : never>
|
|
332
352
|
| undefined
|
|
@@ -337,6 +357,11 @@ export const Service = <Self>() =>
|
|
|
337
357
|
readonly layers: Record<string, Layer.Layer<any, any, any>>
|
|
338
358
|
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>>
|
|
339
359
|
readonly idleTimeToLive?: Duration.DurationInput | undefined
|
|
360
|
+
/**
|
|
361
|
+
* Preloaded entries become idle immediately and follow the idle TTL.
|
|
362
|
+
* The default idle TTL is zero, so preloading only occurs when a nonzero
|
|
363
|
+
* `idleTimeToLive` is configured.
|
|
364
|
+
*/
|
|
340
365
|
readonly preload?: boolean
|
|
341
366
|
}, Options>
|
|
342
367
|
>(
|
|
@@ -357,10 +382,10 @@ export const Service = <Self>() =>
|
|
|
357
382
|
Options extends { readonly dependencies: ReadonlyArray<any> } ? Options["dependencies"][number] : never
|
|
358
383
|
> => {
|
|
359
384
|
const Err = globalThis.Error as any
|
|
360
|
-
const limit =
|
|
361
|
-
|
|
385
|
+
const limit = getStackTraceLimit()
|
|
386
|
+
setStackTraceLimit(2)
|
|
362
387
|
const creationError = new Err()
|
|
363
|
-
|
|
388
|
+
setStackTraceLimit(limit)
|
|
364
389
|
|
|
365
390
|
function TagClass() {}
|
|
366
391
|
const TagClass_ = TagClass as any as Mutable<TagClass<Self, Id, string, any, any, any, any, any>>
|
package/src/Micro.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { format, NodeInspectSymbol, toStringUnknown } from "./Inspectable.js"
|
|
|
21
21
|
import * as InternalContext from "./internal/context.js"
|
|
22
22
|
import * as doNotation from "./internal/doNotation.js"
|
|
23
23
|
import { StructuralPrototype } from "./internal/effectable.js"
|
|
24
|
+
import { getStackTraceLimit, setStackTraceLimit } from "./internal/stackTraceLimit.js"
|
|
24
25
|
import * as Option from "./Option.js"
|
|
25
26
|
import type { Pipeable } from "./Pipeable.js"
|
|
26
27
|
import { pipeArguments } from "./Pipeable.js"
|
|
@@ -3831,10 +3832,10 @@ export const withTrace: {
|
|
|
3831
3832
|
*/
|
|
3832
3833
|
<A, E, R>(self: Micro<A, E, R>, name: string): Micro<A, E, R>
|
|
3833
3834
|
} = function() {
|
|
3834
|
-
const prevLimit =
|
|
3835
|
-
|
|
3835
|
+
const prevLimit = getStackTraceLimit()
|
|
3836
|
+
setStackTraceLimit(2)
|
|
3836
3837
|
const error = new globalThis.Error()
|
|
3837
|
-
|
|
3838
|
+
setStackTraceLimit(prevLimit)
|
|
3838
3839
|
function generate(name: string, cause: MicroCause<any>) {
|
|
3839
3840
|
const stack = error.stack
|
|
3840
3841
|
if (!stack) {
|
package/src/Stream.ts
CHANGED
|
@@ -2638,7 +2638,7 @@ export const execute: <X, E, R>(effect: Effect.Effect<X, E, R>) => Stream<never,
|
|
|
2638
2638
|
* // {
|
|
2639
2639
|
* // _id: 'Exit',
|
|
2640
2640
|
* // _tag: 'Failure',
|
|
2641
|
-
* // cause: { _id: 'Cause', _tag: 'Fail',
|
|
2641
|
+
* // cause: { _id: 'Cause', _tag: 'Fail', error: 'Uh oh!' }
|
|
2642
2642
|
* // }
|
|
2643
2643
|
* ```
|
|
2644
2644
|
*
|
package/src/internal/cause.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type { AnySpan, Span } from "../Tracer.js"
|
|
|
17
17
|
import type * as Types from "../Types.js"
|
|
18
18
|
import { getBugErrorMessage } from "./errors.js"
|
|
19
19
|
import * as OpCodes from "./opCodes/cause.js"
|
|
20
|
+
import { getStackTraceLimit, setStackTraceLimit } from "./stackTraceLimit.js"
|
|
20
21
|
|
|
21
22
|
// -----------------------------------------------------------------------------
|
|
22
23
|
// Models
|
|
@@ -60,7 +61,7 @@ const proto = {
|
|
|
60
61
|
case "Interrupt":
|
|
61
62
|
return { _id: "Cause", _tag: this._tag, fiberId: this.fiberId.toJSON() }
|
|
62
63
|
case "Fail":
|
|
63
|
-
return { _id: "Cause", _tag: this._tag,
|
|
64
|
+
return { _id: "Cause", _tag: this._tag, error: toJSON(this.error) }
|
|
64
65
|
case "Sequential":
|
|
65
66
|
case "Parallel":
|
|
66
67
|
return { _id: "Cause", _tag: this._tag, left: toJSON(this.left), right: toJSON(this.right) }
|
|
@@ -898,19 +899,19 @@ const renderErrorCause = (cause: Cause.PrettyError, prefix: string) => {
|
|
|
898
899
|
/** @internal */
|
|
899
900
|
export const makePrettyError = (originalError: unknown): Cause.PrettyError => {
|
|
900
901
|
const originalErrorIsObject = typeof originalError === "object" && originalError !== null
|
|
901
|
-
const prevLimit =
|
|
902
|
-
|
|
902
|
+
const prevLimit = getStackTraceLimit()
|
|
903
|
+
setStackTraceLimit(1)
|
|
903
904
|
const error = new Error(
|
|
904
905
|
prettyErrorMessage(originalError),
|
|
905
906
|
originalErrorIsObject && "cause" in originalError && typeof originalError.cause !== "undefined"
|
|
906
907
|
? { cause: makePrettyError(originalError.cause) }
|
|
907
908
|
: undefined
|
|
908
909
|
) as Types.Mutable<Cause.PrettyError>
|
|
909
|
-
|
|
910
|
+
setStackTraceLimit(prevLimit)
|
|
910
911
|
if (error.message === "") {
|
|
911
912
|
error.message = "An error has occurred"
|
|
912
913
|
}
|
|
913
|
-
|
|
914
|
+
setStackTraceLimit(prevLimit)
|
|
914
915
|
error.name = originalError instanceof Error ? originalError.name : "Error"
|
|
915
916
|
if (originalErrorIsObject) {
|
|
916
917
|
if (spanSymbol in originalError) {
|