HttpClient Error: socket hang up

I'm a little stumped as to what to do here... the issue seems related to
HttpClient
and the platform layer?
https://effect.website/play/#785a648220d3

src/main.ts(37,3): error TS2345: Argument of type '<A, E, R>(self: Effect<A, E, R>) => Effect<A, SocketError | E, Exclude<R, never>>' is not assignable to parameter of type '(_: Effect<void, ParseError | HttpClientError, Scope | HttpClient<HttpClientError, Scope>>) => Effect<...>'.
  Type 'Effect<void, ParseError | HttpClientError | SocketError, Scope | HttpClient<HttpClientError, Scope>>' is not assignable to type 'Effect<unknown, unknown, never>'.
    Type 'Scope | HttpClient<HttpClientError, Scope>' is not assignable to type 'never'.
      Type 'Scope' is not assignable to type 'never'.


import { NodeRuntime } from "@effect/platform-node"
import { Function, Schema, Effect } from 'effect'
import { HttpClient, HttpClientRequest } from "@effect/platform";
import { DevToolsLive } from "./DevTools"

export type DemoInfo = Schema.Schema.Type<typeof DemoInfo>
const DemoInfo = Schema.Struct({
  url: Schema.NonEmptyString,
  time: Schema.DateFromNumber,
  duration: Schema.Number.pipe(
    Schema.int(),
    Schema.positive(),
  ),
})

const baseRequest = HttpClientRequest.get('https://api.demos.tf/demos/')
const getDemoRequest = (demoId: number) => baseRequest.pipe(
  HttpClientRequest.acceptJson,
  HttpClientRequest.appendUrl(String(demoId)),
)

export const getDemo = Function.flow(
  getDemoRequest,
  HttpClient.execute,
  Effect.flatMap(Function.flow(
    (x) => x.toJSON(),
    Schema.decodeUnknown(DemoInfo),
  ))
)

const program = Effect.gen(function* () {
  const foo = yield* getDemo(1201621)
  console.debug(foo)
})

program.pipe(
  Effect.provide(DevToolsLive),
  NodeRuntime.runMain
)
Was this page helpful?