@effect/platform-node 4.0.0-beta.101 → 4.0.0-beta.103

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 (49) hide show
  1. package/dist/Mime.js.map +1 -1
  2. package/dist/NodeClusterHttp.d.ts +1 -0
  3. package/dist/NodeClusterHttp.d.ts.map +1 -1
  4. package/dist/NodeClusterHttp.js +6 -1
  5. package/dist/NodeClusterHttp.js.map +1 -1
  6. package/dist/NodeClusterSocket.d.ts +1 -0
  7. package/dist/NodeClusterSocket.d.ts.map +1 -1
  8. package/dist/NodeClusterSocket.js +10 -2
  9. package/dist/NodeClusterSocket.js.map +1 -1
  10. package/dist/NodeCrypto.js.map +1 -1
  11. package/dist/NodeFileSystem.js.map +1 -1
  12. package/dist/NodeHttpClient.d.ts +18 -18
  13. package/dist/NodeHttpClient.d.ts.map +1 -1
  14. package/dist/NodeHttpClient.js +25 -19
  15. package/dist/NodeHttpClient.js.map +1 -1
  16. package/dist/NodeHttpIncomingMessage.js.map +1 -1
  17. package/dist/NodeHttpPlatform.d.ts +8 -4
  18. package/dist/NodeHttpPlatform.d.ts.map +1 -1
  19. package/dist/NodeHttpPlatform.js +38 -0
  20. package/dist/NodeHttpPlatform.js.map +1 -1
  21. package/dist/NodeHttpServer.d.ts +21 -16
  22. package/dist/NodeHttpServer.d.ts.map +1 -1
  23. package/dist/NodeHttpServer.js +22 -20
  24. package/dist/NodeHttpServer.js.map +1 -1
  25. package/dist/NodeHttpServerRequest.js.map +1 -1
  26. package/dist/NodeMultipart.js.map +1 -1
  27. package/dist/NodePath.js.map +1 -1
  28. package/dist/NodeRedis.js.map +1 -1
  29. package/dist/NodeRuntime.js.map +1 -1
  30. package/dist/NodeServices.js.map +1 -1
  31. package/dist/NodeSocket.js.map +1 -1
  32. package/dist/NodeStdio.js.map +1 -1
  33. package/dist/NodeTerminal.js.map +1 -1
  34. package/dist/NodeWorker.js.map +1 -1
  35. package/dist/NodeWorkerRunner.d.ts.map +1 -1
  36. package/dist/NodeWorkerRunner.js +30 -18
  37. package/dist/NodeWorkerRunner.js.map +1 -1
  38. package/dist/Undici.d.ts +2 -2
  39. package/dist/Undici.js +2 -2
  40. package/dist/Undici.js.map +1 -1
  41. package/dist/index.js.map +1 -1
  42. package/package.json +10 -11
  43. package/src/NodeClusterHttp.ts +6 -2
  44. package/src/NodeClusterSocket.ts +8 -2
  45. package/src/NodeHttpClient.ts +22 -18
  46. package/src/NodeHttpPlatform.ts +49 -0
  47. package/src/NodeHttpServer.ts +60 -45
  48. package/src/NodeWorkerRunner.ts +39 -23
  49. package/src/Undici.ts +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"NodeWorkerRunner.js","names":["Cause","Deferred","Effect","Exit","Fiber","Layer","WorkerError","WorkerReceiveError","WorkerSpawnError","WorkerRunner","WorkerThreads","layer","succeed","WorkerRunnerPlatform","start","gen","parentPort","process","send","reason","message","sendUnsafe","_portId","transfers","postMessage","_transfers","sync","run","handler","scopedWith","fnUntraced","scope","closeLatch","makeUnsafe","trackFiber","runIn","services","context","runFork","runForkWith","onExit","exit","_tag","hasInterruptsOnly","cause","logError","on","result","isEffect","fiber","addObserver","close","channel","unref","doneUnsafe","void","await"],"sources":["../src/NodeWorkerRunner.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;AAYA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,SAASC,WAAW,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAQ,qCAAqC;AACvG,OAAO,KAAKC,YAAY,MAAM,sCAAsC;AACpE,OAAO,KAAKC,aAAa,MAAM,qBAAqB;AAEpD;;;;;;;;AAQA,OAAO,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AAI,aAAa,CAAC,UAAU,EAAE;YAC5B,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC;YAC5D,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC;UAChD;QACF,CAAC,CAAC,CACH;QAED,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAElB,OAAO,OAAO,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC;MAC1C,CAAC,CAAC,CAAC;MAEL,OAAO;QAAE,GAAG;QAAE,IAAI;QAAE;MAAU,CAAE;IAClC,CAAC,CAAC;EACJ;CACD,CAAC","ignoreList":[]}
package/dist/Undici.d.ts CHANGED
@@ -16,12 +16,12 @@
16
16
  */
17
17
  import Undici from "undici";
18
18
  /**
19
- * @category Undici
19
+ * @category re-exports
20
20
  * @since 4.0.0
21
21
  */
22
22
  export * from "undici";
23
23
  /**
24
- * @category Undici
24
+ * @category re-exports
25
25
  * @since 4.0.0
26
26
  */
27
27
  export default Undici;
package/dist/Undici.js CHANGED
@@ -16,12 +16,12 @@
16
16
  */
17
17
  import Undici from "undici";
18
18
  /**
19
- * @category Undici
19
+ * @category re-exports
20
20
  * @since 4.0.0
21
21
  */
22
22
  export * from "undici";
23
23
  /**
24
- * @category Undici
24
+ * @category re-exports
25
25
  * @since 4.0.0
26
26
  */
27
27
  export default Undici;
@@ -1 +1 @@
1
- {"version":3,"file":"Undici.js","names":["Undici"],"sources":["../src/Undici.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;AAgBA,OAAOA,MAAM,MAAM,QAAQ;AAE3B;;;;AAIA,cAAc,QAAQ;AAEtB;;;;AAIA,eAAeA,MAAM","ignoreList":[]}
1
+ {"version":3,"file":"Undici.js","names":[],"sources":["../src/Undici.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;AAgBA,OAAO,MAAM,MAAM,QAAQ;AAE3B;;;;AAIA,cAAc,QAAQ;AAEtB;;;;AAIA,eAAe,MAAM","ignoreList":[]}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Mime","NodeChildProcessSpawner","NodeClusterHttp","NodeClusterSocket","NodeCrypto","NodeFileSystem","NodeHttpClient","NodeHttpIncomingMessage","NodeHttpPlatform","NodeHttpServer","NodeHttpServerRequest","NodeMultipart","NodePath","NodeRedis","NodeRuntime","NodeServices","NodeSink","NodeSocket","NodeSocketServer","NodeStdio","NodeStream","NodeTerminal","NodeWorker","NodeWorkerRunner","Undici"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AAEA;;;AAGA,OAAO,KAAKA,IAAI,MAAM,WAAW;AAEjC;;;AAGA,OAAO,KAAKC,uBAAuB,MAAM,8BAA8B;AAEvE;;;AAGA,OAAO,KAAKC,eAAe,MAAM,sBAAsB;AAEvD;;;AAGA,OAAO,KAAKC,iBAAiB,MAAM,wBAAwB;AAE3D;;;AAGA,OAAO,KAAKC,UAAU,MAAM,iBAAiB;AAE7C;;;AAGA,OAAO,KAAKC,cAAc,MAAM,qBAAqB;AAErD;;;AAGA,OAAO,KAAKC,cAAc,MAAM,qBAAqB;AAErD;;;AAGA,OAAO,KAAKC,uBAAuB,MAAM,8BAA8B;AAEvE;;;AAGA,OAAO,KAAKC,gBAAgB,MAAM,uBAAuB;AAEzD;;;AAGA,OAAO,KAAKC,cAAc,MAAM,qBAAqB;AAErD;;;AAGA,OAAO,KAAKC,qBAAqB,MAAM,4BAA4B;AAEnE;;;AAGA,OAAO,KAAKC,aAAa,MAAM,oBAAoB;AAEnD;;;AAGA,OAAO,KAAKC,QAAQ,MAAM,eAAe;AAEzC;;;AAGA,OAAO,KAAKC,SAAS,MAAM,gBAAgB;AAE3C;;;AAGA,OAAO,KAAKC,WAAW,MAAM,kBAAkB;AAE/C;;;AAGA,OAAO,KAAKC,YAAY,MAAM,mBAAmB;AAEjD;;;AAGA,OAAO,KAAKC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;AAE/C;;;AAGA,OAAO,KAAK,YAAY,MAAM,mBAAmB;AAEjD;;;AAGA,OAAO,KAAK,QAAQ,MAAM,eAAe;AAEzC;;;AAGA,OAAO,KAAK,UAAU,MAAM,iBAAiB;AAE7C;;;AAGA,OAAO,KAAK,gBAAgB,MAAM,uBAAuB;AAEzD;;;AAGA,OAAO,KAAK,SAAS,MAAM,gBAAgB;AAE3C;;;AAGA,OAAO,KAAK,UAAU,MAAM,iBAAiB;AAE7C;;;AAGA,OAAO,KAAK,YAAY,MAAM,mBAAmB;AAEjD;;;AAGA,OAAO,KAAK,UAAU,MAAM,iBAAiB;AAE7C;;;AAGA,OAAO,KAAK,gBAAgB,MAAM,uBAAuB;AAEzD;;;AAGA,OAAO,KAAK,MAAM,MAAM,aAAa","ignoreList":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@effect/platform-node",
3
3
  "type": "module",
4
- "version": "4.0.0-beta.101",
4
+ "version": "4.0.0-beta.103",
5
5
  "license": "MIT",
6
6
  "description": "Platform specific implementations for the Node.js runtime",
7
7
  "homepage": "https://effect.website",
@@ -34,6 +34,7 @@
34
34
  ".": "./dist/index.js",
35
35
  "./*": "./dist/*.js",
36
36
  "./internal/*": null,
37
+ "./index": null,
37
38
  "./*/index": null
38
39
  },
39
40
  "files": [
@@ -50,25 +51,23 @@
50
51
  "dependencies": {
51
52
  "mime": "^4.1.0",
52
53
  "undici": "^8.7.0",
53
- "@effect/platform-node-shared": "^4.0.0-beta.101"
54
+ "@effect/platform-node-shared": "^4.0.0-beta.103"
54
55
  },
55
56
  "peerDependencies": {
56
57
  "ioredis": "^5.7.0",
57
- "effect": "^4.0.0-beta.101"
58
+ "effect": "^4.0.0-beta.103"
58
59
  },
59
60
  "devDependencies": {
60
- "@testcontainers/mysql": "^11.14.0",
61
- "@testcontainers/postgresql": "^11.14.0",
62
- "@testcontainers/redis": "^11.14.0",
63
- "@types/node": "^26.1.1",
64
- "effect": "^4.0.0-beta.101"
61
+ "@testcontainers/mysql": "^12.0.4",
62
+ "@testcontainers/postgresql": "^12.0.4",
63
+ "@testcontainers/redis": "^12.0.4",
64
+ "@types/node": "^26.1.2",
65
+ "effect": "^4.0.0-beta.103"
65
66
  },
66
67
  "scripts": {
67
68
  "codegen": "effect-utils codegen",
68
69
  "build": "tsc -b tsconfig.json && pnpm babel",
69
70
  "babel": "babel dist --plugins annotate-pure-calls --out-dir dist --source-maps",
70
- "check": "tsc -b tsconfig.json",
71
- "test": "vitest",
72
- "coverage": "vitest --coverage"
71
+ "check": "tsc -b tsconfig.json"
73
72
  }
74
73
  }
@@ -31,6 +31,7 @@ import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization"
31
31
  import type { SqlClient } from "effect/unstable/sql/SqlClient"
32
32
  import { createServer } from "node:http"
33
33
  import { layerK8sHttpClient } from "./NodeClusterSocket.ts"
34
+ import * as NodeCrypto from "./NodeCrypto.ts"
34
35
  import * as NodeHttpClient from "./NodeHttpClient.ts"
35
36
  import * as NodeHttpServer from "./NodeHttpServer.ts"
36
37
  import type { NodeServices } from "./NodeServices.ts"
@@ -60,6 +61,7 @@ export const layer = <
60
61
  >(options: {
61
62
  readonly transport: "http" | "websocket"
62
63
  readonly serialization?: "msgpack" | "ndjson" | undefined
64
+ readonly serializationMaxBufferSize?: number | "unbounded" | undefined
63
65
  readonly clientOnly?: ClientOnly | undefined
64
66
  readonly storage?: Storage | undefined
65
67
  readonly runnerHealth?: "ping" | "k8s" | undefined
@@ -115,7 +117,7 @@ export const layer = <
115
117
  ? MessageStorage.layerNoop
116
118
  : options?.storage === "byo"
117
119
  ? Layer.empty
118
- : Layer.orDie(SqlMessageStorage.layer)
120
+ : Layer.orDie(SqlMessageStorage.layer).pipe(Layer.provide(NodeCrypto.layer))
119
121
  ),
120
122
  Layer.provide(
121
123
  options?.storage === "local"
@@ -126,7 +128,9 @@ export const layer = <
126
128
  ),
127
129
  Layer.provide(ShardingConfig.layerFromEnv(options?.shardingConfig)),
128
130
  Layer.provide(
129
- options?.serialization === "ndjson" ? RpcSerialization.layerNdjson : RpcSerialization.layerMsgPack
131
+ options?.serialization === "ndjson"
132
+ ? RpcSerialization.layerNdjsonWith({ maxBufferSize: options.serializationMaxBufferSize })
133
+ : RpcSerialization.layerMsgPackWith({ maxBufferSize: options.serializationMaxBufferSize })
130
134
  )
131
135
  ) as any
132
136
  }
@@ -28,6 +28,7 @@ import * as SqlRunnerStorage from "effect/unstable/cluster/SqlRunnerStorage"
28
28
  import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization"
29
29
  import type * as SocketServer from "effect/unstable/socket/SocketServer"
30
30
  import type { SqlClient } from "effect/unstable/sql/SqlClient"
31
+ import * as NodeCrypto from "./NodeCrypto.ts"
31
32
  import * as NodeFileSystem from "./NodeFileSystem.ts"
32
33
  import * as NodeHttpClient from "./NodeHttpClient.ts"
33
34
  import * as Undici from "./Undici.ts"
@@ -65,6 +66,7 @@ export const layer = <
65
66
  >(
66
67
  options?: {
67
68
  readonly serialization?: "msgpack" | "ndjson" | undefined
69
+ readonly serializationMaxBufferSize?: number | "unbounded" | undefined
68
70
  readonly clientOnly?: ClientOnly | undefined
69
71
  readonly storage?: Storage | undefined
70
72
  readonly runnerHealth?: "ping" | "k8s" | undefined
@@ -113,7 +115,7 @@ export const layer = <
113
115
  ? MessageStorage.layerNoop
114
116
  : options?.storage === "byo"
115
117
  ? Layer.empty
116
- : Layer.orDie(SqlMessageStorage.layer)
118
+ : Layer.orDie(SqlMessageStorage.layer).pipe(Layer.provide(NodeCrypto.layer))
117
119
  ),
118
120
  Layer.provide(
119
121
  options?.storage === "local"
@@ -124,7 +126,9 @@ export const layer = <
124
126
  ),
125
127
  Layer.provide(ShardingConfig.layerFromEnv(options?.shardingConfig)),
126
128
  Layer.provide(
127
- options?.serialization === "ndjson" ? RpcSerialization.layerNdjson : RpcSerialization.layerMsgPack
129
+ options?.serialization === "ndjson"
130
+ ? RpcSerialization.layerNdjsonWith({ maxBufferSize: options?.serializationMaxBufferSize })
131
+ : RpcSerialization.layerMsgPackWith({ maxBufferSize: options?.serializationMaxBufferSize })
128
132
  )
129
133
  ) as any
130
134
  }
@@ -146,6 +150,8 @@ export const layerDispatcherK8s: Layer.Layer<NodeHttpClient.Dispatcher> = Layer.
146
150
  if (caCertOption._tag === "Some") {
147
151
  return yield* Effect.acquireRelease(
148
152
  Effect.sync(() =>
153
+ // oxlint cannot resolve values re-exported through the local Undici facade.
154
+ // oxlint-disable-next-line import/namespace
149
155
  new Undici.Agent({
150
156
  connect: {
151
157
  ca: caCertOption.value
@@ -51,14 +51,14 @@ export {
51
51
  * Use to access or override the fetch implementation used by the Node
52
52
  * fetch-based HTTP client.
53
53
  *
54
- * @category fetch
54
+ * @category services
55
55
  * @since 4.0.0
56
56
  */
57
57
  Fetch,
58
58
  /**
59
59
  * Layer that provides the fetch-based HTTP client implementation.
60
60
  *
61
- * @category fetch
61
+ * @category layers
62
62
  * @since 4.0.0
63
63
  */
64
64
  layer as layerFetch,
@@ -69,7 +69,7 @@ export {
69
69
  *
70
70
  * Use to provide default fetch request options for Node HTTP requests.
71
71
  *
72
- * @category fetch
72
+ * @category services
73
73
  * @since 4.0.0
74
74
  */
75
75
  RequestInit
@@ -83,7 +83,7 @@ export {
83
83
  * Service tag for the Undici `Dispatcher` used by the Undici-backed HTTP
84
84
  * client.
85
85
  *
86
- * @category Dispatcher
86
+ * @category services
87
87
  * @since 4.0.0
88
88
  */
89
89
  export class Dispatcher extends Context.Service<Dispatcher, Undici.Dispatcher>()(
@@ -94,10 +94,12 @@ export class Dispatcher extends Context.Service<Dispatcher, Undici.Dispatcher>()
94
94
  * Acquires a new Undici `Agent` dispatcher and destroys it when the enclosing
95
95
  * scope is finalized.
96
96
  *
97
- * @category Dispatcher
97
+ * @category resource management
98
98
  * @since 4.0.0
99
99
  */
100
100
  export const makeDispatcher: Effect.Effect<Undici.Dispatcher, never, Scope.Scope> = Effect.acquireRelease(
101
+ // oxlint cannot resolve values re-exported through the local Undici facade.
102
+ // oxlint-disable-next-line import/namespace
101
103
  Effect.sync(() => new Undici.Agent()),
102
104
  (dispatcher) => Effect.promise(() => dispatcher.destroy())
103
105
  )
@@ -105,7 +107,7 @@ export const makeDispatcher: Effect.Effect<Undici.Dispatcher, never, Scope.Scope
105
107
  /**
106
108
  * Provides the `Dispatcher` service using a scoped Undici `Agent`.
107
109
  *
108
- * @category Dispatcher
110
+ * @category layers
109
111
  * @since 4.0.0
110
112
  */
111
113
  export const layerDispatcher: Layer.Layer<Dispatcher> = Layer.effect(Dispatcher)(makeDispatcher)
@@ -114,16 +116,18 @@ export const layerDispatcher: Layer.Layer<Dispatcher> = Layer.effect(Dispatcher)
114
116
  * Provides the `Dispatcher` service from Undici's process-global dispatcher,
115
117
  * without creating or owning a new agent.
116
118
  *
117
- * @category Dispatcher
119
+ * @category layers
118
120
  * @since 4.0.0
119
121
  */
122
+ // oxlint cannot resolve values re-exported through the local Undici facade.
123
+ // oxlint-disable-next-line import/namespace
120
124
  export const dispatcherLayerGlobal: Layer.Layer<Dispatcher> = Layer.sync(Dispatcher)(() => Undici.getGlobalDispatcher())
121
125
 
122
126
  /**
123
127
  * Fiber reference containing default Undici request options applied to requests
124
128
  * sent by `makeUndici`.
125
129
  *
126
- * @category Undici
130
+ * @category services
127
131
  * @since 4.0.0
128
132
  */
129
133
  export const UndiciOptions = Context.Reference<Partial<Undici.Dispatcher.RequestOptions>>(
@@ -136,7 +140,7 @@ export const UndiciOptions = Context.Reference<Partial<Undici.Dispatcher.Request
136
140
  * `Dispatcher`, converts Effect HTTP bodies to Undici bodies, and maps
137
141
  * transport and decode failures to `HttpClientError`.
138
142
  *
139
- * @category Undici
143
+ * @category constructors
140
144
  * @since 4.0.0
141
145
  */
142
146
  export const makeUndici = Effect.gen(function*() {
@@ -353,7 +357,7 @@ class UndiciResponse extends Inspectable.Class implements HttpClientResponse, Pi
353
357
  * Provides an Undici-backed `HttpClient` using the current `Dispatcher`
354
358
  * service.
355
359
  *
356
- * @category Undici
360
+ * @category layers
357
361
  * @since 4.0.0
358
362
  */
359
363
  export const layerUndiciNoDispatcher: Layer.Layer<
@@ -366,7 +370,7 @@ export const layerUndiciNoDispatcher: Layer.Layer<
366
370
  * Provides an Undici-backed `HttpClient` together with a scoped default
367
371
  * Undici `Agent` dispatcher.
368
372
  *
369
- * @category Undici
373
+ * @category layers
370
374
  * @since 4.0.0
371
375
  */
372
376
  export const layerUndici: Layer.Layer<Client.HttpClient> = Layer.provide(layerUndiciNoDispatcher, layerDispatcher)
@@ -379,7 +383,7 @@ export const layerUndici: Layer.Layer<Client.HttpClient> = Layer.provide(layerUn
379
383
  * Service tag for the paired Node `http` and `https` agents used by the
380
384
  * node:http-backed HTTP client.
381
385
  *
382
- * @category HttpAgent
386
+ * @category services
383
387
  * @since 4.0.0
384
388
  */
385
389
  export class HttpAgent extends Context.Service<HttpAgent, {
@@ -391,7 +395,7 @@ export class HttpAgent extends Context.Service<HttpAgent, {
391
395
  * Acquires Node `http` and `https` agents with the supplied options and
392
396
  * destroys both agents when the enclosing scope is finalized.
393
397
  *
394
- * @category HttpAgent
398
+ * @category resource management
395
399
  * @since 4.0.0
396
400
  */
397
401
  export const makeAgent = (options?: Https.AgentOptions): Effect.Effect<HttpAgent["Service"], never, Scope.Scope> =>
@@ -411,7 +415,7 @@ export const makeAgent = (options?: Https.AgentOptions): Effect.Effect<HttpAgent
411
415
  * Provides the `HttpAgent` service using scoped Node `http` and `https`
412
416
  * agents configured with the supplied options.
413
417
  *
414
- * @category HttpAgent
418
+ * @category layers
415
419
  * @since 4.0.0
416
420
  */
417
421
  export const layerAgentOptions: (options?: Https.AgentOptions | undefined) => Layer.Layer<
@@ -422,7 +426,7 @@ export const layerAgentOptions: (options?: Https.AgentOptions | undefined) => La
422
426
  * Provides the `HttpAgent` service using default scoped Node `http` and
423
427
  * `https` agents.
424
428
  *
425
- * @category HttpAgent
429
+ * @category layers
426
430
  * @since 4.0.0
427
431
  */
428
432
  export const layerAgent: Layer.Layer<HttpAgent> = layerAgentOptions()
@@ -432,7 +436,7 @@ export const layerAgent: Layer.Layer<HttpAgent> = layerAgentOptions()
432
436
  * current `HttpAgent`, streaming request bodies, and wrapping Node responses
433
437
  * as `HttpClientResponse` values.
434
438
  *
435
- * @category node:http
439
+ * @category constructors
436
440
  * @since 4.0.0
437
441
  */
438
442
  export const makeNodeHttp = Effect.gen(function*() {
@@ -645,7 +649,7 @@ class NodeHttpResponse extends NodeHttpIncomingMessage<Error.HttpClientError> im
645
649
  * Provides a node:http-backed `HttpClient` using the current `HttpAgent`
646
650
  * service.
647
651
  *
648
- * @category node:http
652
+ * @category layers
649
653
  * @since 4.0.0
650
654
  */
651
655
  export const layerNodeHttpNoAgent: Layer.Layer<
@@ -658,7 +662,7 @@ export const layerNodeHttpNoAgent: Layer.Layer<
658
662
  * Provides a node:http-backed `HttpClient` together with default scoped Node
659
663
  * `http` and `https` agents.
660
664
  *
661
- * @category node:http
665
+ * @category layers
662
666
  * @since 4.0.0
663
667
  */
664
668
  export const layerNodeHttp: Layer.Layer<Client.HttpClient> = Layer.provide(layerNodeHttpNoAgent, layerAgent)
@@ -8,16 +8,63 @@
8
8
  *
9
9
  * @since 4.0.0
10
10
  */
11
+ import * as NodeHttpCompression from "@effect/platform-node-shared/NodeHttpCompression"
12
+ import * as Effect from "effect/Effect"
11
13
  import { pipe } from "effect/Function"
12
14
  import * as Layer from "effect/Layer"
13
15
  import * as EtagImpl from "effect/unstable/http/Etag"
14
16
  import * as Headers from "effect/unstable/http/Headers"
17
+ import * as HttpBody from "effect/unstable/http/HttpBody"
15
18
  import * as Platform from "effect/unstable/http/HttpPlatform"
16
19
  import * as ServerResponse from "effect/unstable/http/HttpServerResponse"
17
20
  import * as Fs from "node:fs"
18
21
  import { Readable } from "node:stream"
19
22
  import Mime from "./Mime.ts"
20
23
  import * as NodeFileSystem from "./NodeFileSystem.ts"
24
+ import * as NodeStream from "./NodeStream.ts"
25
+
26
+ // replaces the response body while keeping every other field, dropping the
27
+ // now-stale Content-Length header
28
+ const compressedBody = (
29
+ response: ServerResponse.HttpServerResponse,
30
+ body: HttpBody.HttpBody
31
+ ): ServerResponse.HttpServerResponse =>
32
+ ServerResponse.removeHeader(ServerResponse.setBody(response, body), "content-length")
33
+
34
+ const compression = NodeHttpCompression.make({
35
+ algorithms: NodeHttpCompression.algorithms,
36
+ compressResponse(response, algorithm, options) {
37
+ const body = response.body
38
+ switch (body._tag) {
39
+ case "Stream": {
40
+ return Effect.succeed(compressedBody(
41
+ response,
42
+ HttpBody.stream(
43
+ NodeStream.pipeThroughDuplex(body.stream, {
44
+ evaluate: () => NodeHttpCompression.compressTransform(algorithm, options)
45
+ }),
46
+ body.contentType
47
+ )
48
+ ))
49
+ }
50
+ case "Raw": {
51
+ const readable = body.body instanceof Readable
52
+ ? body.body
53
+ : Readable.fromWeb(new Response(body.body as BodyInit).body as any)
54
+ const transform = NodeHttpCompression.compressTransform(algorithm, options)
55
+ readable.on("error", (cause) => transform.destroy(cause))
56
+ transform.on("error", (cause) => readable.destroy(cause))
57
+ transform.on("close", () => readable.destroy())
58
+ return Effect.succeed(
59
+ compressedBody(response, HttpBody.raw(readable.pipe(transform), { contentType: body.contentType }))
60
+ )
61
+ }
62
+ default: {
63
+ return Effect.succeed(response)
64
+ }
65
+ }
66
+ }
67
+ })
21
68
 
22
69
  /**
23
70
  * Creates the Node `HttpPlatform`, serving file responses from Node readable
@@ -27,6 +74,8 @@ import * as NodeFileSystem from "./NodeFileSystem.ts"
27
74
  * @since 4.0.0
28
75
  */
29
76
  export const make = Platform.make({
77
+ platform: "node",
78
+ compression,
30
79
  fileResponse(path, status, statusText, headers, start, end, contentLength) {
31
80
  const stream = contentLength === 0
32
81
  ? Readable.from([])
@@ -62,6 +62,26 @@ import * as NodeMultipart from "./NodeMultipart.ts"
62
62
  import * as NodeServices from "./NodeServices.ts"
63
63
  import { NodeWS } from "./NodeSocket.ts"
64
64
 
65
+ /**
66
+ * Options accepted by the Node `HttpServer` constructors and layers.
67
+ *
68
+ * @category options
69
+ * @since 4.0.0
70
+ */
71
+ export interface Options extends Net.ListenOptions {
72
+ readonly disablePreemptiveShutdown?: boolean | undefined
73
+ readonly gracefulShutdownTimeout?: Duration.Input | undefined
74
+ /**
75
+ * Options forwarded to the underlying `ws` `WebSocketServer`, minus the
76
+ * wiring options the server manages itself. Use this to enable
77
+ * `permessage-deflate` compression or tune payload limits, e.g.
78
+ * `websocket: { perMessageDeflate: true }`.
79
+ */
80
+ readonly websocket?:
81
+ | Omit<NodeWS.ServerOptions, "noServer" | "server" | "host" | "port" | "path">
82
+ | undefined
83
+ }
84
+
65
85
  /**
66
86
  * Creates a scoped `HttpServer` from a Node `http.Server`, starts listening
67
87
  * with the supplied options, registers request and upgrade handling, and closes
@@ -72,10 +92,7 @@ import { NodeWS } from "./NodeSocket.ts"
72
92
  */
73
93
  export const make = Effect.fnUntraced(function*(
74
94
  evaluate: LazyArg<Http.Server>,
75
- options: Net.ListenOptions & {
76
- readonly disablePreemptiveShutdown?: boolean | undefined
77
- readonly gracefulShutdownTimeout?: Duration.Input | undefined
78
- }
95
+ options: Options
79
96
  ) {
80
97
  const scope = yield* Effect.scope
81
98
  const server = evaluate()
@@ -116,7 +133,7 @@ export const make = Effect.fnUntraced(function*(
116
133
  const address = server.address()!
117
134
 
118
135
  const wss = yield* Effect.acquireRelease(
119
- Effect.sync(() => new NodeWS.WebSocketServer({ noServer: true })),
136
+ Effect.sync(() => new NodeWS.WebSocketServer({ ...options.websocket, noServer: true })),
120
137
  (wss) =>
121
138
  Effect.callback<void>((resume) => {
122
139
  wss.close(() => resume(Effect.void))
@@ -189,9 +206,8 @@ export const makeHandler = <
189
206
  nodeRequest: Http.IncomingMessage,
190
207
  nodeResponse: Http.ServerResponse
191
208
  ) {
192
- const map = new Map(services.mapUnsafe)
193
- map.set(HttpServerRequest.key, new ServerRequestImpl(nodeRequest, nodeResponse))
194
- const fiber = Fiber.runIn(Effect.runForkWith(Context.makeUnsafe<any>(map))(handled), options.scope)
209
+ const context = Context.add(services, HttpServerRequest, new ServerRequestImpl(nodeRequest, nodeResponse))
210
+ const fiber = Fiber.runIn(Effect.runForkWith(context as Context.Context<any>)(handled), options.scope)
195
211
  nodeResponse.on("close", () => {
196
212
  if (!nodeResponse.writableEnded) {
197
213
  fiber.interruptUnsafe(parent.id, ClientAbort.annotation)
@@ -256,9 +272,12 @@ export const makeUpgradeHandler = <
256
272
  (ws) => Effect.sync(() => ws.close())
257
273
  )
258
274
  ))
259
- const map = new Map(services.mapUnsafe)
260
- map.set(HttpServerRequest.key, new ServerRequestImpl(nodeRequest, nodeResponse, upgradeEffect))
261
- const fiber = Fiber.runIn(Effect.runForkWith(Context.makeUnsafe<any>(map))(handledApp), options.scope)
275
+ const context = Context.add(
276
+ services,
277
+ HttpServerRequest,
278
+ new ServerRequestImpl(nodeRequest, nodeResponse, upgradeEffect)
279
+ )
280
+ const fiber = Fiber.runIn(Effect.runForkWith(context as Context.Context<any>)(handledApp), options.scope)
262
281
  socket.on("close", () => {
263
282
  if (!socket.writableEnded) {
264
283
  fiber.interruptUnsafe(parent.id, ClientAbort.annotation)
@@ -330,8 +349,9 @@ class ServerRequestImpl extends NodeHttpIncomingMessage<HttpServerError> impleme
330
349
  return this.source.url!
331
350
  }
332
351
 
352
+ private cachedMethod: HttpMethod | undefined
333
353
  get method(): HttpMethod {
334
- return this.source.method!.toUpperCase() as HttpMethod
354
+ return this.cachedMethod ??= this.source.method!.toUpperCase() as HttpMethod
335
355
  }
336
356
 
337
357
  override get headers(): Headers.Headers {
@@ -397,10 +417,7 @@ class ServerRequestImpl extends NodeHttpIncomingMessage<HttpServerError> impleme
397
417
  */
398
418
  export const layerServer: (
399
419
  evaluate: LazyArg<Http.Server<typeof Http.IncomingMessage, typeof Http.ServerResponse>>,
400
- options: Net.ListenOptions & {
401
- readonly disablePreemptiveShutdown?: boolean | undefined
402
- readonly gracefulShutdownTimeout?: Duration.Input | undefined
403
- }
420
+ options: Options
404
421
  ) => Layer.Layer<HttpServer.HttpServer, ServeError> = flow(make, Layer.effect(HttpServer.HttpServer))
405
422
 
406
423
  /**
@@ -427,10 +444,7 @@ export const layerHttpServices: Layer.Layer<
427
444
  */
428
445
  export const layer = (
429
446
  evaluate: LazyArg<Http.Server>,
430
- options: Net.ListenOptions & {
431
- readonly disablePreemptiveShutdown?: boolean | undefined
432
- readonly gracefulShutdownTimeout?: Duration.Input | undefined
433
- }
447
+ options: Options
434
448
  ): Layer.Layer<
435
449
  HttpServer.HttpServer | NodeServices.NodeServices | HttpPlatform.HttpPlatform | Etag.Generator,
436
450
  ServeError
@@ -450,12 +464,7 @@ export const layer = (
450
464
  */
451
465
  export const layerConfig = (
452
466
  evaluate: LazyArg<Http.Server>,
453
- options: Config.Wrap<
454
- Net.ListenOptions & {
455
- readonly disablePreemptiveShutdown?: boolean | undefined
456
- readonly gracefulShutdownTimeout?: Duration.Input | undefined
457
- }
458
- >
467
+ options: Config.Wrap<Options>
459
468
  ): Layer.Layer<
460
469
  HttpServer.HttpServer | NodeServices.NodeServices | HttpPlatform.HttpPlatform | Etag.Generator,
461
470
  ServeError | Config.ConfigError
@@ -517,14 +526,20 @@ const handleResponse = (
517
526
 
518
527
  if (request.method === "HEAD") {
519
528
  nodeResponse.writeHead(response.status, headers)
520
- return Effect.callback<void>((resume) => {
521
- const done = () => {
522
- nodeResponse.off("close", done)
523
- resume(Effect.void)
524
- }
525
- nodeResponse.once("close", done)
526
- nodeResponse.end(done)
527
- })
529
+ return Effect.andThen(
530
+ cancelResponseBody(response.body),
531
+ Effect.callback<void>((resume) => {
532
+ let completed = false
533
+ const done = () => {
534
+ if (completed) return
535
+ completed = true
536
+ nodeResponse.off("close", done)
537
+ resume(Effect.void)
538
+ }
539
+ nodeResponse.once("close", done)
540
+ nodeResponse.end(done)
541
+ })
542
+ )
528
543
  }
529
544
  const body = response.body
530
545
  switch (body._tag) {
@@ -608,17 +623,9 @@ const handleResponse = (
608
623
  return body.stream.pipe(
609
624
  Stream.orDie,
610
625
  Stream.runForEachArray((array) => {
611
- let needDrain = false
612
- for (let i = 0; i < array.length; i++) {
613
- const written = nodeResponse.write(array[i])
614
- if (!written && !needDrain) {
615
- needDrain = true
616
- drainLatch.closeUnsafe()
617
- } else if (written && needDrain) {
618
- needDrain = false
619
- }
620
- }
621
- if (!needDrain) return Effect.void
626
+ const chunk = array.length > 1 ? Buffer.concat(array) : array[0]
627
+ if (nodeResponse.write(chunk)) return Effect.void
628
+ drainLatch.closeUnsafe()
622
629
  return drainLatch.await
623
630
  }),
624
631
  Effect.interruptible,
@@ -631,6 +638,14 @@ const handleResponse = (
631
638
  }
632
639
  }
633
640
 
641
+ const cancelResponseBody = (body: HttpServerResponse["body"]): Effect.Effect<void> => {
642
+ const stream = body._tag === "Raw" ? body.body : undefined
643
+ if (stream instanceof Readable) {
644
+ return Effect.sync(() => stream.destroy())
645
+ }
646
+ return Effect.void
647
+ }
648
+
634
649
  const handleCause = (
635
650
  nodeResponse: Http.ServerResponse,
636
651
  originalResponse: HttpServerResponse