@effect/platform 0.78.1 → 0.79.1
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/README.md +15 -51
- package/dist/cjs/HttpApiBuilder.js +1 -1
- package/dist/cjs/HttpApiClient.js +1 -1
- package/dist/cjs/HttpApiClient.js.map +1 -1
- package/dist/cjs/HttpClient.js.map +1 -1
- package/dist/cjs/HttpClientResponse.js.map +1 -1
- package/dist/cjs/HttpMethod.js +1 -2
- package/dist/cjs/HttpMethod.js.map +1 -1
- package/dist/cjs/UrlParams.js +2 -0
- package/dist/cjs/UrlParams.js.map +1 -1
- package/dist/cjs/internal/httpClient.js +126 -13
- package/dist/cjs/internal/httpClient.js.map +1 -1
- package/dist/cjs/internal/httpClientResponse.js +1 -1
- package/dist/cjs/internal/httpClientResponse.js.map +1 -1
- package/dist/cjs/internal/workerRunner.js +9 -2
- package/dist/cjs/internal/workerRunner.js.map +1 -1
- package/dist/dts/HttpApiBuilder.d.ts +1 -1
- package/dist/dts/HttpApiClient.d.ts +3 -4
- package/dist/dts/HttpApiClient.d.ts.map +1 -1
- package/dist/dts/HttpClient.d.ts +11 -12
- package/dist/dts/HttpClient.d.ts.map +1 -1
- package/dist/dts/HttpClientResponse.d.ts +1 -2
- package/dist/dts/HttpClientResponse.d.ts.map +1 -1
- package/dist/dts/HttpMethod.d.ts +1 -2
- package/dist/dts/HttpMethod.d.ts.map +1 -1
- package/dist/dts/UrlParams.d.ts +2 -0
- package/dist/dts/UrlParams.d.ts.map +1 -1
- package/dist/dts/internal/httpClient.d.ts +8 -9
- package/dist/dts/internal/httpClient.d.ts.map +1 -1
- package/dist/esm/HttpApiBuilder.js +1 -1
- package/dist/esm/HttpApiClient.js +1 -1
- package/dist/esm/HttpApiClient.js.map +1 -1
- package/dist/esm/HttpClient.js.map +1 -1
- package/dist/esm/HttpClientResponse.js.map +1 -1
- package/dist/esm/HttpMethod.js +1 -2
- package/dist/esm/HttpMethod.js.map +1 -1
- package/dist/esm/UrlParams.js +2 -0
- package/dist/esm/UrlParams.js.map +1 -1
- package/dist/esm/internal/httpClient.js +125 -12
- package/dist/esm/internal/httpClient.js.map +1 -1
- package/dist/esm/internal/httpClientResponse.js +1 -1
- package/dist/esm/internal/httpClientResponse.js.map +1 -1
- package/dist/esm/internal/workerRunner.js +9 -2
- package/dist/esm/internal/workerRunner.js.map +1 -1
- package/package.json +2 -2
- package/src/HttpApiBuilder.ts +1 -1
- package/src/HttpApiClient.ts +4 -6
- package/src/HttpClient.ts +11 -13
- package/src/HttpClientResponse.ts +1 -2
- package/src/HttpMethod.ts +1 -2
- package/src/UrlParams.ts +2 -0
- package/src/internal/httpClient.ts +176 -52
- package/src/internal/httpClientResponse.ts +1 -1
- package/src/internal/workerRunner.ts +13 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workerRunner.js","names":["Cause","Chunk","Context","Deferred","Effect","Either","Fiber","FiberId","pipe","Layer","Schema","Stream","Transferable","isWorkerError","WorkerError","PlatformRunnerTypeId","Symbol","for","PlatformRunner","GenericTag","CloseLatch","Reference","defaultValue","unsafeMake","none","layerCloseLatch","effect","make","fnUntraced","process","options","platform","closeLatch","backing","start","fiberMap","Map","
|
|
1
|
+
{"version":3,"file":"workerRunner.js","names":["Cause","Chunk","Context","Deferred","Effect","Either","Fiber","FiberId","pipe","Layer","Schema","Stream","Transferable","isWorkerError","WorkerError","PlatformRunnerTypeId","Symbol","for","PlatformRunner","GenericTag","CloseLatch","Reference","defaultValue","unsafeMake","none","layerCloseLatch","effect","make","fnUntraced","process","options","fiber","withFiberRuntime","succeed","platform","closeLatch","backing","start","fiberMap","Map","await","onExit","currentScheduler","scheduleTask","unsafeInterruptAsFork","id","void","forkScoped","run","portId","kind","data","span","get","interrupt","set","decode","flatMap","input","collector","unsafeMakeCollector","stream","isEffect","out","encodeOutput","provideService","Collector","payload","send","unsafeRead","runForEachChunk","chunk","undefined","toReadonlyArray","unsafeClear","forEach","andThen","withParentSpan","_tag","traceId","spanId","sampled","context","empty","uninterruptibleMask","restore","catchIf","error","encodeCause","fail","catchAllCause","cause","match","failureOrCause","onLeft","encodeError","onRight","ensuring","sync","delete","layer","scopedDiscard","provide","makeSerialized","schema","handlers","gen","scope","parseRequest","decodeUnknown","request","result","isLayer","buildWithScope","_","merge","provideContext","message","mapError","reason","serializeFailure","serializeSuccess","layerSerialized","launch","scopedWith","provideMerge"],"sources":["../../../src/internal/workerRunner.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,OAAO,MAAM,gBAAgB;AACzC,SAASC,IAAI,QAAQ,iBAAiB;AACtC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,YAAY,MAAM,oBAAoB;AAElD,SAASC,aAAa,EAAEC,WAAW,QAAQ,mBAAmB;AAG9D;AACA,OAAO,MAAMC,oBAAoB,gBAAsCC,MAAM,CAACC,GAAG,CAC/E,wCAAwC,CACJ;AAEtC;AACA,OAAO,MAAMC,cAAc,gBAAGhB,OAAO,CAACiB,UAAU,CAC9C,wCAAwC,CACzC;AAED;AACA,OAAO,MAAMC,UAAU,gBAAGlB,OAAO,CAACmB,SAAS,EAA2B,CAAC,0CAA0C,EAAE;EACjHC,YAAY,EAAEA,CAAA,KAAMnB,QAAQ,CAACoB,UAAU,CAAoBhB,OAAO,CAACiB,IAAI;CACxE,CAAC;AAEF;AACA,OAAO,MAAMC,eAAe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|
1
1
|
{
|
|
2
2
|
"name": "@effect/platform",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.79.1",
|
|
4
4
|
"description": "Unified interfaces for common platform-specific services",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"multipasta": "^0.2.5"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"effect": "^3.13.
|
|
17
|
+
"effect": "^3.13.10"
|
|
18
18
|
},
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"provenance": true
|
package/src/HttpApiBuilder.ts
CHANGED
|
@@ -1045,7 +1045,7 @@ export const securityDecode = <Security extends HttpApiSecurity.HttpApiSecurity>
|
|
|
1045
1045
|
*
|
|
1046
1046
|
* You can use this api before returning a response from an endpoint handler.
|
|
1047
1047
|
*
|
|
1048
|
-
* ```ts
|
|
1048
|
+
* ```ts skip-type-checking
|
|
1049
1049
|
* handlers.handle(
|
|
1050
1050
|
* "authenticate",
|
|
1051
1051
|
* (_) => HttpApiBuilder.securitySetCookie(security, "secret123")
|
package/src/HttpApiClient.ts
CHANGED
|
@@ -10,7 +10,6 @@ import * as ParseResult from "effect/ParseResult"
|
|
|
10
10
|
import type * as Predicate from "effect/Predicate"
|
|
11
11
|
import * as Schema from "effect/Schema"
|
|
12
12
|
import type * as AST from "effect/SchemaAST"
|
|
13
|
-
import type { Scope } from "effect/Scope"
|
|
14
13
|
import type { Simplify } from "effect/Types"
|
|
15
14
|
import * as HttpApi from "./HttpApi.js"
|
|
16
15
|
import type { HttpApiEndpoint } from "./HttpApiEndpoint.js"
|
|
@@ -130,7 +129,7 @@ const makeClient = <ApiId extends string, Groups extends HttpApiGroup.Any, ApiEr
|
|
|
130
129
|
}) => void
|
|
131
130
|
readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined
|
|
132
131
|
readonly transformResponse?:
|
|
133
|
-
| ((effect: Effect.Effect<unknown, unknown
|
|
132
|
+
| ((effect: Effect.Effect<unknown, unknown>) => Effect.Effect<unknown, unknown>)
|
|
134
133
|
| undefined
|
|
135
134
|
readonly baseUrl?: string | undefined
|
|
136
135
|
}
|
|
@@ -223,7 +222,6 @@ const makeClient = <ApiId extends string, Groups extends HttpApiGroup.Any, ApiEr
|
|
|
223
222
|
: options.transformResponse(decodeResponse(response)))
|
|
224
223
|
return request?.withResponse === true ? [value, response] : value
|
|
225
224
|
}).pipe(
|
|
226
|
-
Effect.scoped,
|
|
227
225
|
Effect.mapInputContext((input) => Context.merge(context, input))
|
|
228
226
|
)
|
|
229
227
|
|
|
@@ -244,7 +242,7 @@ export const make = <ApiId extends string, Groups extends HttpApiGroup.Any, ApiE
|
|
|
244
242
|
options?: {
|
|
245
243
|
readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined
|
|
246
244
|
readonly transformResponse?:
|
|
247
|
-
| ((effect: Effect.Effect<unknown, unknown
|
|
245
|
+
| ((effect: Effect.Effect<unknown, unknown>) => Effect.Effect<unknown, unknown>)
|
|
248
246
|
| undefined
|
|
249
247
|
readonly baseUrl?: string | undefined
|
|
250
248
|
}
|
|
@@ -282,7 +280,7 @@ export const group = <
|
|
|
282
280
|
options?: {
|
|
283
281
|
readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined
|
|
284
282
|
readonly transformResponse?:
|
|
285
|
-
| ((effect: Effect.Effect<unknown, unknown
|
|
283
|
+
| ((effect: Effect.Effect<unknown, unknown>) => Effect.Effect<unknown, unknown>)
|
|
286
284
|
| undefined
|
|
287
285
|
readonly baseUrl?: string | undefined
|
|
288
286
|
}
|
|
@@ -324,7 +322,7 @@ export const endpoint = <
|
|
|
324
322
|
options?: {
|
|
325
323
|
readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined
|
|
326
324
|
readonly transformResponse?:
|
|
327
|
-
| ((effect: Effect.Effect<unknown, unknown
|
|
325
|
+
| ((effect: Effect.Effect<unknown, unknown>) => Effect.Effect<unknown, unknown>)
|
|
328
326
|
| undefined
|
|
329
327
|
readonly baseUrl?: string | undefined
|
|
330
328
|
}
|
package/src/HttpClient.ts
CHANGED
|
@@ -11,7 +11,6 @@ import type { Pipeable } from "effect/Pipeable"
|
|
|
11
11
|
import type * as Predicate from "effect/Predicate"
|
|
12
12
|
import type { Ref } from "effect/Ref"
|
|
13
13
|
import type * as Schedule from "effect/Schedule"
|
|
14
|
-
import type * as Scope from "effect/Scope"
|
|
15
14
|
import type { NoExcessProperties, NoInfer } from "effect/Types"
|
|
16
15
|
import type { Cookies } from "./Cookies.js"
|
|
17
16
|
import type * as Error from "./HttpClientError.js"
|
|
@@ -35,7 +34,7 @@ export type TypeId = typeof TypeId
|
|
|
35
34
|
* @since 1.0.0
|
|
36
35
|
* @category models
|
|
37
36
|
*/
|
|
38
|
-
export interface HttpClient extends HttpClient.With<Error.HttpClientError
|
|
37
|
+
export interface HttpClient extends HttpClient.With<Error.HttpClientError> {}
|
|
39
38
|
|
|
40
39
|
/**
|
|
41
40
|
* @since 1.0.0
|
|
@@ -45,7 +44,7 @@ export declare namespace HttpClient {
|
|
|
45
44
|
* @since 1.0.0
|
|
46
45
|
* @category models
|
|
47
46
|
*/
|
|
48
|
-
export interface With<E, R> extends Pipeable, Inspectable {
|
|
47
|
+
export interface With<E, R = never> extends Pipeable, Inspectable {
|
|
49
48
|
readonly [TypeId]: TypeId
|
|
50
49
|
readonly execute: (
|
|
51
50
|
request: ClientRequest.HttpClientRequest
|
|
@@ -110,8 +109,7 @@ export const HttpClient: Context.Tag<HttpClient, HttpClient> = internal.tag
|
|
|
110
109
|
*/
|
|
111
110
|
export const execute: (
|
|
112
111
|
request: ClientRequest.HttpClientRequest
|
|
113
|
-
) => Effect.Effect<ClientResponse.HttpClientResponse, Error.HttpClientError,
|
|
114
|
-
internal.execute
|
|
112
|
+
) => Effect.Effect<ClientResponse.HttpClientResponse, Error.HttpClientError, HttpClient> = internal.execute
|
|
115
113
|
|
|
116
114
|
/**
|
|
117
115
|
* @since 1.0.0
|
|
@@ -123,7 +121,7 @@ export const get: (
|
|
|
123
121
|
) => Effect.Effect<
|
|
124
122
|
ClientResponse.HttpClientResponse,
|
|
125
123
|
Error.HttpClientError,
|
|
126
|
-
|
|
124
|
+
HttpClient
|
|
127
125
|
> = internal.get
|
|
128
126
|
|
|
129
127
|
/**
|
|
@@ -136,7 +134,7 @@ export const head: (
|
|
|
136
134
|
) => Effect.Effect<
|
|
137
135
|
ClientResponse.HttpClientResponse,
|
|
138
136
|
Error.HttpClientError,
|
|
139
|
-
|
|
137
|
+
HttpClient
|
|
140
138
|
> = internal.head
|
|
141
139
|
|
|
142
140
|
/**
|
|
@@ -149,7 +147,7 @@ export const post: (
|
|
|
149
147
|
) => Effect.Effect<
|
|
150
148
|
ClientResponse.HttpClientResponse,
|
|
151
149
|
Error.HttpClientError,
|
|
152
|
-
|
|
150
|
+
HttpClient
|
|
153
151
|
> = internal.post
|
|
154
152
|
|
|
155
153
|
/**
|
|
@@ -162,7 +160,7 @@ export const patch: (
|
|
|
162
160
|
) => Effect.Effect<
|
|
163
161
|
ClientResponse.HttpClientResponse,
|
|
164
162
|
Error.HttpClientError,
|
|
165
|
-
|
|
163
|
+
HttpClient
|
|
166
164
|
> = internal.patch
|
|
167
165
|
|
|
168
166
|
/**
|
|
@@ -175,7 +173,7 @@ export const put: (
|
|
|
175
173
|
) => Effect.Effect<
|
|
176
174
|
ClientResponse.HttpClientResponse,
|
|
177
175
|
Error.HttpClientError,
|
|
178
|
-
|
|
176
|
+
HttpClient
|
|
179
177
|
> = internal.put
|
|
180
178
|
|
|
181
179
|
/**
|
|
@@ -188,7 +186,7 @@ export const del: (
|
|
|
188
186
|
) => Effect.Effect<
|
|
189
187
|
ClientResponse.HttpClientResponse,
|
|
190
188
|
Error.HttpClientError,
|
|
191
|
-
|
|
189
|
+
HttpClient
|
|
192
190
|
> = internal.del
|
|
193
191
|
|
|
194
192
|
/**
|
|
@@ -201,7 +199,7 @@ export const options: (
|
|
|
201
199
|
) => Effect.Effect<
|
|
202
200
|
ClientResponse.HttpClientResponse,
|
|
203
201
|
Error.HttpClientError,
|
|
204
|
-
|
|
202
|
+
HttpClient
|
|
205
203
|
> = internal.options
|
|
206
204
|
|
|
207
205
|
/**
|
|
@@ -414,7 +412,7 @@ export const make: (
|
|
|
414
412
|
url: URL,
|
|
415
413
|
signal: AbortSignal,
|
|
416
414
|
fiber: RuntimeFiber<ClientResponse.HttpClientResponse, Error.HttpClientError>
|
|
417
|
-
) => Effect.Effect<ClientResponse.HttpClientResponse, Error.HttpClientError
|
|
415
|
+
) => Effect.Effect<ClientResponse.HttpClientResponse, Error.HttpClientError>
|
|
418
416
|
) => HttpClient = internal.make
|
|
419
417
|
|
|
420
418
|
/**
|
|
@@ -5,7 +5,6 @@ import type * as Effect from "effect/Effect"
|
|
|
5
5
|
import type * as ParseResult from "effect/ParseResult"
|
|
6
6
|
import type * as Schema from "effect/Schema"
|
|
7
7
|
import type { ParseOptions } from "effect/SchemaAST"
|
|
8
|
-
import type * as Scope from "effect/Scope"
|
|
9
8
|
import type * as Stream from "effect/Stream"
|
|
10
9
|
import type { Unify } from "effect/Unify"
|
|
11
10
|
import type * as Cookies from "./Cookies.js"
|
|
@@ -103,7 +102,7 @@ export const schemaNoBody: <
|
|
|
103
102
|
*/
|
|
104
103
|
export const stream: <E, R>(
|
|
105
104
|
effect: Effect.Effect<HttpClientResponse, E, R>
|
|
106
|
-
) => Stream.Stream<Uint8Array, Error.ResponseError | E,
|
|
105
|
+
) => Stream.Stream<Uint8Array, Error.ResponseError | E, R> = internal.stream
|
|
107
106
|
|
|
108
107
|
/**
|
|
109
108
|
* @since 1.0.0
|
package/src/HttpMethod.ts
CHANGED
|
@@ -42,10 +42,9 @@ export const all: ReadonlySet<HttpMethod> = new Set(["GET", "POST", "PUT", "DELE
|
|
|
42
42
|
/**
|
|
43
43
|
* Tests if a value is a `HttpMethod`.
|
|
44
44
|
*
|
|
45
|
-
* @param input - The value to test.
|
|
46
|
-
*
|
|
47
45
|
* @example
|
|
48
46
|
* ```ts
|
|
47
|
+
* import * as assert from "node:assert"
|
|
49
48
|
* import { HttpMethod } from "@effect/platform"
|
|
50
49
|
*
|
|
51
50
|
* assert.deepStrictEqual(HttpMethod.isHttpMethod("GET"), true)
|
package/src/UrlParams.ts
CHANGED
|
@@ -281,6 +281,7 @@ const baseUrl = (): string | undefined => {
|
|
|
281
281
|
*
|
|
282
282
|
* @example
|
|
283
283
|
* ```ts
|
|
284
|
+
* import * as assert from "node:assert"
|
|
284
285
|
* import { UrlParams } from "@effect/platform"
|
|
285
286
|
*
|
|
286
287
|
* const urlParams = UrlParams.fromInput({ a: 1, b: true, c: "string", e: [1, 2, 3] })
|
|
@@ -335,6 +336,7 @@ export const schemaJson = <A, I, R>(schema: Schema.Schema<A, I, R>, options?: Pa
|
|
|
335
336
|
*
|
|
336
337
|
* @example
|
|
337
338
|
* ```ts
|
|
339
|
+
* import * as assert from "node:assert"
|
|
338
340
|
* import { Effect, Schema } from "effect"
|
|
339
341
|
* import { UrlParams } from "@effect/platform"
|
|
340
342
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Cause from "effect/Cause"
|
|
2
2
|
import * as Context from "effect/Context"
|
|
3
3
|
import * as Effect from "effect/Effect"
|
|
4
|
+
import * as Exit from "effect/Exit"
|
|
4
5
|
import type * as Fiber from "effect/Fiber"
|
|
5
6
|
import * as FiberRef from "effect/FiberRef"
|
|
6
7
|
import { constFalse, dual } from "effect/Function"
|
|
@@ -11,7 +12,7 @@ import { pipeArguments } from "effect/Pipeable"
|
|
|
11
12
|
import * as Predicate from "effect/Predicate"
|
|
12
13
|
import * as Ref from "effect/Ref"
|
|
13
14
|
import * as Schedule from "effect/Schedule"
|
|
14
|
-
import * as
|
|
15
|
+
import * as Stream from "effect/Stream"
|
|
15
16
|
import type { NoExcessProperties, NoInfer } from "effect/Types"
|
|
16
17
|
import * as Cookies from "../Cookies.js"
|
|
17
18
|
import * as Headers from "../Headers.js"
|
|
@@ -19,6 +20,7 @@ import type * as Client from "../HttpClient.js"
|
|
|
19
20
|
import * as Error from "../HttpClientError.js"
|
|
20
21
|
import type * as ClientRequest from "../HttpClientRequest.js"
|
|
21
22
|
import type * as ClientResponse from "../HttpClientResponse.js"
|
|
23
|
+
import * as IncomingMessage from "../HttpIncomingMessage.js"
|
|
22
24
|
import * as TraceContext from "../HttpTraceContext.js"
|
|
23
25
|
import * as UrlParams from "../UrlParams.js"
|
|
24
26
|
import * as internalRequest from "./httpClientRequest.js"
|
|
@@ -123,6 +125,38 @@ export const makeWith = <E2, R2, E, R>(
|
|
|
123
125
|
return self
|
|
124
126
|
}
|
|
125
127
|
|
|
128
|
+
const responseRegistry = globalValue(
|
|
129
|
+
"@effect/platform/HttpClient/responseRegistry",
|
|
130
|
+
() => {
|
|
131
|
+
if ("FinalizationRegistry" in globalThis && globalThis.FinalizationRegistry) {
|
|
132
|
+
const registry = new FinalizationRegistry((controller: AbortController) => {
|
|
133
|
+
controller.abort()
|
|
134
|
+
})
|
|
135
|
+
return {
|
|
136
|
+
register(response: ClientResponse.HttpClientResponse, controller: AbortController) {
|
|
137
|
+
registry.register(response, controller, response)
|
|
138
|
+
},
|
|
139
|
+
unregister(response: ClientResponse.HttpClientResponse) {
|
|
140
|
+
registry.unregister(response)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const timers = new Map<ClientResponse.HttpClientResponse, any>()
|
|
146
|
+
return {
|
|
147
|
+
register(response: ClientResponse.HttpClientResponse, controller: AbortController) {
|
|
148
|
+
timers.set(response, setTimeout(() => controller.abort(), 5000))
|
|
149
|
+
},
|
|
150
|
+
unregister(response: ClientResponse.HttpClientResponse) {
|
|
151
|
+
const timer = timers.get(response)
|
|
152
|
+
if (timer === undefined) return
|
|
153
|
+
clearTimeout(timer)
|
|
154
|
+
timers.delete(response)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
|
|
126
160
|
/** @internal */
|
|
127
161
|
export const make = (
|
|
128
162
|
f: (
|
|
@@ -130,14 +164,12 @@ export const make = (
|
|
|
130
164
|
url: URL,
|
|
131
165
|
signal: AbortSignal,
|
|
132
166
|
fiber: Fiber.RuntimeFiber<ClientResponse.HttpClientResponse, Error.HttpClientError>
|
|
133
|
-
) => Effect.Effect<ClientResponse.HttpClientResponse, Error.HttpClientError
|
|
167
|
+
) => Effect.Effect<ClientResponse.HttpClientResponse, Error.HttpClientError>
|
|
134
168
|
): Client.HttpClient =>
|
|
135
169
|
makeWith((effect) =>
|
|
136
170
|
Effect.flatMap(effect, (request) =>
|
|
137
171
|
Effect.withFiberRuntime((fiber) => {
|
|
138
|
-
const scope = Context.unsafeGet(fiber.getFiberRef(FiberRef.currentContext), Scope.Scope)
|
|
139
172
|
const controller = new AbortController()
|
|
140
|
-
const addAbort = Scope.addFinalizer(scope, Effect.sync(() => controller.abort()))
|
|
141
173
|
const urlResult = UrlParams.makeUrl(request.url, request.urlParams, request.hash)
|
|
142
174
|
if (urlResult._tag === "Left") {
|
|
143
175
|
return Effect.fail(new Error.RequestError({ request, reason: "InvalidUrl", cause: urlResult.left }))
|
|
@@ -146,60 +178,152 @@ export const make = (
|
|
|
146
178
|
const tracerDisabled = !fiber.getFiberRef(FiberRef.currentTracerEnabled) ||
|
|
147
179
|
fiber.getFiberRef(currentTracerDisabledWhen)(request)
|
|
148
180
|
if (tracerDisabled) {
|
|
149
|
-
return Effect.
|
|
150
|
-
|
|
151
|
-
|
|
181
|
+
return Effect.uninterruptibleMask((restore) =>
|
|
182
|
+
Effect.matchCauseEffect(restore(f(request, url, controller.signal, fiber)), {
|
|
183
|
+
onSuccess(response) {
|
|
184
|
+
responseRegistry.register(response, controller)
|
|
185
|
+
return Effect.succeed(new InterruptibleResponse(response, controller))
|
|
186
|
+
},
|
|
187
|
+
onFailure(cause) {
|
|
188
|
+
if (Cause.isInterrupted(cause)) {
|
|
189
|
+
controller.abort()
|
|
190
|
+
}
|
|
191
|
+
return Effect.failCause(cause)
|
|
192
|
+
}
|
|
193
|
+
})
|
|
152
194
|
)
|
|
153
195
|
}
|
|
154
|
-
return Effect.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
(
|
|
160
|
-
|
|
161
|
-
span.attribute("server.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
request
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
Effect.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
196
|
+
return Effect.useSpan(
|
|
197
|
+
`http.client ${request.method}`,
|
|
198
|
+
{ kind: "client", captureStackTrace: false },
|
|
199
|
+
(span) => {
|
|
200
|
+
span.attribute("http.request.method", request.method)
|
|
201
|
+
span.attribute("server.address", url.origin)
|
|
202
|
+
if (url.port !== "") {
|
|
203
|
+
span.attribute("server.port", +url.port)
|
|
204
|
+
}
|
|
205
|
+
span.attribute("url.full", url.toString())
|
|
206
|
+
span.attribute("url.path", url.pathname)
|
|
207
|
+
span.attribute("url.scheme", url.protocol.slice(0, -1))
|
|
208
|
+
const query = url.search.slice(1)
|
|
209
|
+
if (query !== "") {
|
|
210
|
+
span.attribute("url.query", query)
|
|
211
|
+
}
|
|
212
|
+
const redactedHeaderNames = fiber.getFiberRef(Headers.currentRedactedNames)
|
|
213
|
+
const redactedHeaders = Headers.redact(request.headers, redactedHeaderNames)
|
|
214
|
+
for (const name in redactedHeaders) {
|
|
215
|
+
span.attribute(`http.request.header.${name}`, String(redactedHeaders[name]))
|
|
216
|
+
}
|
|
217
|
+
request = fiber.getFiberRef(currentTracerPropagation)
|
|
218
|
+
? internalRequest.setHeaders(request, TraceContext.toHeaders(span))
|
|
219
|
+
: request
|
|
220
|
+
return Effect.uninterruptibleMask((restore) =>
|
|
221
|
+
restore(f(request, url, controller.signal, fiber)).pipe(
|
|
222
|
+
Effect.withParentSpan(span),
|
|
223
|
+
Effect.matchCauseEffect({
|
|
224
|
+
onSuccess: (response) => {
|
|
225
|
+
span.attribute("http.response.status_code", response.status)
|
|
226
|
+
const redactedHeaders = Headers.redact(response.headers, redactedHeaderNames)
|
|
227
|
+
for (const name in redactedHeaders) {
|
|
228
|
+
span.attribute(`http.response.header.${name}`, String(redactedHeaders[name]))
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
responseRegistry.register(response, controller)
|
|
232
|
+
return Effect.succeed(new InterruptibleResponse(response, controller))
|
|
233
|
+
},
|
|
234
|
+
onFailure(cause) {
|
|
235
|
+
if (Cause.isInterrupted(cause)) {
|
|
236
|
+
controller.abort()
|
|
237
|
+
}
|
|
238
|
+
return Effect.failCause(cause)
|
|
195
239
|
}
|
|
196
|
-
}
|
|
240
|
+
})
|
|
197
241
|
)
|
|
198
|
-
|
|
199
|
-
|
|
242
|
+
)
|
|
243
|
+
}
|
|
200
244
|
)
|
|
201
245
|
})), Effect.succeed as Client.HttpClient.Preprocess<never, never>)
|
|
202
246
|
|
|
247
|
+
class InterruptibleResponse implements ClientResponse.HttpClientResponse {
|
|
248
|
+
constructor(
|
|
249
|
+
readonly original: ClientResponse.HttpClientResponse,
|
|
250
|
+
readonly controller: AbortController
|
|
251
|
+
) {}
|
|
252
|
+
|
|
253
|
+
readonly [internalResponse.TypeId]: ClientResponse.TypeId = internalResponse.TypeId
|
|
254
|
+
readonly [IncomingMessage.TypeId]: IncomingMessage.TypeId = IncomingMessage.TypeId
|
|
255
|
+
|
|
256
|
+
private applyInterrupt<A, E, R>(effect: Effect.Effect<A, E, R>) {
|
|
257
|
+
return Effect.suspend(() => {
|
|
258
|
+
responseRegistry.unregister(this.original)
|
|
259
|
+
return Effect.onInterrupt(effect, () =>
|
|
260
|
+
Effect.sync(() => {
|
|
261
|
+
this.controller.abort()
|
|
262
|
+
}))
|
|
263
|
+
})
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
get request() {
|
|
267
|
+
return this.original.request
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
get status() {
|
|
271
|
+
return this.original.status
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
get headers() {
|
|
275
|
+
return this.original.headers
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
get cookies() {
|
|
279
|
+
return this.original.cookies
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
get remoteAddress() {
|
|
283
|
+
return this.original.remoteAddress
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
get formData() {
|
|
287
|
+
return this.applyInterrupt(this.original.formData)
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
get text() {
|
|
291
|
+
return this.applyInterrupt(this.original.text)
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
get json() {
|
|
295
|
+
return this.applyInterrupt(this.original.json)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
get urlParamsBody() {
|
|
299
|
+
return this.applyInterrupt(this.original.urlParamsBody)
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
get arrayBuffer() {
|
|
303
|
+
return this.applyInterrupt(this.original.arrayBuffer)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
get stream() {
|
|
307
|
+
return Stream.suspend(() => {
|
|
308
|
+
responseRegistry.unregister(this.original)
|
|
309
|
+
return Stream.ensuringWith(this.original.stream, (exit) => {
|
|
310
|
+
if (Exit.isInterrupted(exit)) {
|
|
311
|
+
this.controller.abort()
|
|
312
|
+
}
|
|
313
|
+
return Effect.void
|
|
314
|
+
})
|
|
315
|
+
})
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
toJSON() {
|
|
319
|
+
return this.original.toJSON()
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
[Inspectable.NodeInspectSymbol]() {
|
|
323
|
+
return this.original[Inspectable.NodeInspectSymbol]()
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
203
327
|
export const {
|
|
204
328
|
/** @internal */
|
|
205
329
|
del,
|
|
@@ -733,6 +857,6 @@ export const layerMergedContext = <E, R>(
|
|
|
733
857
|
Effect.map(effect, (client) =>
|
|
734
858
|
transformResponse(
|
|
735
859
|
client,
|
|
736
|
-
Effect.mapInputContext((input: Context.Context<
|
|
860
|
+
Effect.mapInputContext((input: Context.Context<never>) => Context.merge(context, input))
|
|
737
861
|
)))
|
|
738
862
|
)
|
|
@@ -196,7 +196,7 @@ export const schemaNoBody = <
|
|
|
196
196
|
|
|
197
197
|
/** @internal */
|
|
198
198
|
export const stream = <E, R>(effect: Effect.Effect<ClientResponse.HttpClientResponse, E, R>) =>
|
|
199
|
-
Stream.
|
|
199
|
+
Stream.unwrap(Effect.map(effect, (_) => _.stream))
|
|
200
200
|
|
|
201
201
|
/** @internal */
|
|
202
202
|
export const matchStatus = dual<
|
|
@@ -39,11 +39,22 @@ export const make = Effect.fnUntraced(function*<I, E, R, O>(
|
|
|
39
39
|
process: (request: I) => Stream.Stream<O, E, R> | Effect.Effect<O, E, R>,
|
|
40
40
|
options?: WorkerRunner.Runner.Options<I, O, E>
|
|
41
41
|
) {
|
|
42
|
+
const fiber = yield* Effect.withFiberRuntime<Fiber.RuntimeFiber<void>>(Effect.succeed as any)
|
|
42
43
|
const platform = yield* PlatformRunner
|
|
43
44
|
const closeLatch = yield* CloseLatch
|
|
44
45
|
const backing = yield* platform.start<Worker.Worker.Request<I>, Worker.Worker.Response<E>>(closeLatch)
|
|
45
46
|
const fiberMap = new Map<number, Fiber.Fiber<unknown, unknown>>()
|
|
46
47
|
|
|
48
|
+
yield* Deferred.await(closeLatch).pipe(
|
|
49
|
+
Effect.onExit(() => {
|
|
50
|
+
fiber.currentScheduler.scheduleTask(() => {
|
|
51
|
+
fiber.unsafeInterruptAsFork(fiber.id())
|
|
52
|
+
}, 0)
|
|
53
|
+
return Effect.void
|
|
54
|
+
}),
|
|
55
|
+
Effect.forkScoped
|
|
56
|
+
)
|
|
57
|
+
|
|
47
58
|
yield* backing.run((portId, [id, kind, data, span]): Effect.Effect<void, WorkerError, R> => {
|
|
48
59
|
if (kind === 1) {
|
|
49
60
|
const fiber = fiberMap.get(id)
|
|
@@ -211,9 +222,7 @@ export const layerSerialized = <
|
|
|
211
222
|
/** @internal */
|
|
212
223
|
export const launch = <A, E, R>(layer: Layer.Layer<A, E, R>): Effect.Effect<void, E | WorkerError, R> =>
|
|
213
224
|
Effect.scopedWith(Effect.fnUntraced(function*(scope) {
|
|
214
|
-
const context = yield* Layer.buildWithScope(Layer.
|
|
225
|
+
const context = yield* Layer.buildWithScope(Layer.provideMerge(layer, layerCloseLatch), scope)
|
|
215
226
|
const closeLatch = Context.get(context, CloseLatch)
|
|
216
|
-
return yield*
|
|
217
|
-
Effect.raceFirst(Deferred.await(closeLatch))
|
|
218
|
-
)
|
|
227
|
+
return yield* Deferred.await(closeLatch)
|
|
219
228
|
}))
|