fix: controller is already closed trpc subscription observable error (#743)

This commit is contained in:
Meier Lukas
2024-07-03 20:31:06 +02:00
committed by GitHub
parent f557fbbae1
commit 41dba7b516
6 changed files with 33 additions and 12 deletions

View File

@@ -1,11 +1,9 @@
import { TRPCError } from "@trpc/server";
import { observable } from "@trpc/server/observable";
import { createSaltAsync, hashPasswordAsync } from "@homarr/auth";
import type { Database } from "@homarr/db";
import { and, createId, eq, schema } from "@homarr/db";
import { groupMembers, groupPermissions, groups, invites, users } from "@homarr/db/schema/sqlite";
import { exampleChannel } from "@homarr/redis";
import { validation, z } from "@homarr/validation";
import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";
@@ -232,16 +230,6 @@ export const userRouter = createTRPCRouter({
})
.where(eq(users.id, input.userId));
}),
setMessage: publicProcedure.input(z.string()).mutation(async ({ input }) => {
await exampleChannel.publishAsync({ message: input });
}),
test: publicProcedure.subscription(() => {
return observable<{ message: string }>((emit) => {
exampleChannel.subscribe((message) => {
emit.next(message);
});
});
}),
});
const createUserAsync = async (db: Database, input: z.infer<typeof validation.user.create>) => {