mirror of
https://github.com/ajnart/homarr.git
synced 2026-01-30 03:09:19 +01:00
* fix: memory leak caused by many unclosed redis subscriptions * chore: address pull request feedback
23 lines
644 B
TypeScript
23 lines
644 B
TypeScript
import { observable } from "@trpc/server/observable";
|
|
|
|
import { logger } from "@homarr/log";
|
|
import type { LoggerMessage } from "@homarr/redis";
|
|
import { loggingChannel } from "@homarr/redis";
|
|
|
|
import { createTRPCRouter, publicProcedure } from "../trpc";
|
|
|
|
export const logRouter = createTRPCRouter({
|
|
subscribe: publicProcedure.subscription(() => {
|
|
return observable<LoggerMessage>((emit) => {
|
|
const unsubscribe = loggingChannel.subscribe((data) => {
|
|
emit.next(data);
|
|
});
|
|
logger.info("A tRPC client has connected to the logging procedure");
|
|
|
|
return () => {
|
|
unsubscribe();
|
|
};
|
|
});
|
|
}),
|
|
});
|