Skip to content

Commit

Permalink
remove Scope requirement from NodeHttpServer.makeHandler (#3779)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Oct 13, 2024
1 parent 73947b5 commit 3bcdfb3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-pugs-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/platform-node": patch
---

remove Scope requirement from NodeHttpServer.makeHandler
8 changes: 4 additions & 4 deletions packages/platform-node/src/NodeHttpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ export const makeHandler: {
<R, E>(
httpApp: App.Default<E, R>
): Effect.Effect<
(nodeRequest: Http.IncomingMessage, nodeResponse: Http.ServerResponse<Http.IncomingMessage>) => void,
(nodeRequest: Http.IncomingMessage, nodeResponse: Http.ServerResponse) => void,
never,
Exclude<R, Scope.Scope | ServerRequest.HttpServerRequest>
Exclude<R, ServerRequest.HttpServerRequest | Scope.Scope>
>
<R, E, App extends App.Default<any, any>>(
httpApp: App.Default<E, R>,
middleware: Middleware.HttpMiddleware.Applied<App, E, R>
): Effect.Effect<
(nodeRequest: Http.IncomingMessage, nodeResponse: Http.ServerResponse<Http.IncomingMessage>) => void,
(nodeRequest: Http.IncomingMessage, nodeResponse: Http.ServerResponse) => void,
never,
Exclude<Effect.Effect.Context<App>, Scope.Scope | ServerRequest.HttpServerRequest>
Exclude<Effect.Effect.Context<App>, ServerRequest.HttpServerRequest | Scope.Scope>
>
} = internal.makeHandler

Expand Down
9 changes: 6 additions & 3 deletions packages/platform-node/src/internal/httpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { type LazyArg } from "effect/Function"
import * as Layer from "effect/Layer"
import * as Option from "effect/Option"
import type { ReadonlyRecord } from "effect/Record"
import * as Runtime from "effect/Runtime"
import * as Scope from "effect/Scope"
import * as Stream from "effect/Stream"
import * as Http from "node:http"
Expand Down Expand Up @@ -134,8 +135,9 @@ export const makeHandler: {
>
} = <E, R>(httpApp: App.Default<E, R>, middleware?: Middleware.HttpMiddleware) => {
const handledApp = App.toHandled(httpApp, handleResponse, middleware)
return Effect.map(FiberSet.makeRuntime<R>(), (runFork) =>
function handler(
return Effect.map(Effect.runtime<R>(), (runtime) => {
const runFork = Runtime.runFork(runtime)
return function handler(
nodeRequest: Http.IncomingMessage,
nodeResponse: Http.ServerResponse
) {
Expand All @@ -151,7 +153,8 @@ export const makeHandler: {
fiber.unsafeInterruptAsFork(Error.clientAbortFiberId)
}
})
})
}
})
}

/** @internal */
Expand Down

0 comments on commit 3bcdfb3

Please sign in to comment.