tRPCttRPC
Powered by
kulaK
tRPC•12mo ago
kula

How can I break this loop when the client disconnects?

onReceiveMessage: protectedProcedure
.input(receiveSchema)
.subscription(async function* ({ ctx, input }) {
let lastCheck = input.lastMessageTime ?? Date.now()

while (true) {
await new Promise(resolve => setTimeout(resolve, 1000))
}
})

I am currently finding issues with not receiving events from client closures in NextJS.
How can I break this loop when the client disconnects?

When I use Observable, I can exit the loop but Observable is deprecated

trpc version is 11.0.0-rc.446
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

How can I reset the cursor when using useInfiniteQuery?
AdnanAAdnan / ❓-help
3y ago
Anyone had this cryptic ts error when creating the client?
Answer OverflowAAnswer Overflow / ❓-help
3y ago