Effect CommunityEC
Effect Community2y ago
6 replies
Pietro

RuntimeException: @effect/rpc: handler must return an array of responses with the same length as the

I've honestly no idea, I've been looking at this code for the last two days, it stopped working with error in the title after upgrading the effect-ts packages, I've tried debugging but with no luck

If I remove either the CreateContest or the GetContest the RuntimeException goes away

// TestLiveServer.ts
export const EnvLive = Layer.mergeAll(
  NodeContext.layer,
  NodeHttpServer.layer(createServer, { port: 1234 }),
  NodeHttpClient.layerWithoutAgent,
).pipe(Layer.provide(NodeHttpClient.makeAgentLayer({ keepAlive: false })));

export const client = pipe(
  HttpClient.fetch,
  HttpClient.mapRequest(HttpRequest.prependUrl(`http://0.0.0.0:1234/rpc`)),
  HttpResolverNoStream.make<ContestIORouter>,
  Resolver.toClient,
);

// Schema.ts
export class GetContest extends S.TaggedRequest<GetContest>()(
  "GetContest",
  S.Union(NotFound, DbError),
  DT.Contest,
  { id: DT.ContestId },
) {}

// e2e.test.ts
import { beforeAll, beforeEach, describe, expect, it } from "@effect/vitest";

  it.scoped("Create contest", () =>
    Effect.gen(function* () {
      yield* serve;
      console.error("Error creating contest");

      const created = yield* client(new RS.CreateContest(contestInit));
      const contestId = created.id;
      const updated = yield* client(new RS.GetContest({ id: contestId }));
      expect(updated).toMatchObject(contestInit);
    }).pipe(Effect.provide(EnvLive)),
  );
Was this page helpful?