From 61051faef8e6f104212909ec3c5f71e2c1c21097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Pallar=C3=A9s?= Date: Mon, 26 Aug 2024 16:55:38 +0200 Subject: [PATCH] feat(console): use http batch streams The HTTP batch stream links in TRPC can resolve individually as soon as their responses finished streaming, making the batch stream faster than a normal batch. --- apps/wing-console/console/ui/src/Console.tsx | 26 +++----------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/apps/wing-console/console/ui/src/Console.tsx b/apps/wing-console/console/ui/src/Console.tsx index 5d13294da3e..353b61168f9 100644 --- a/apps/wing-console/console/ui/src/Console.tsx +++ b/apps/wing-console/console/ui/src/Console.tsx @@ -1,10 +1,9 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { - httpBatchLink, wsLink, splitLink, createWSClient, - httpLink, + unstable_httpBatchStreamLink, } from "@trpc/client"; import type { Mode } from "@wingconsole/design-system"; import type { Trace } from "@wingconsole/server"; @@ -61,7 +60,6 @@ export const Console = ({ const [trpcClient] = useState(() => trpc.createClient({ links: [ - // For subscriptions, use WebSocket. splitLink({ condition(op) { return op.type === "subscription"; @@ -69,26 +67,8 @@ export const Console = ({ true: wsLink({ client: wsClient, }), - // For the `test.*` operations, use a single HTTP link. This is necessary - // to avoid a bug where the Console would not display the data until - // the app starts correctly. For example, starting a new application - // with compilation errors, the Console will be stuck. - // - // For the rest of the operations, use the batch HTTP link. - // - // We should be able to use batch HTTP links everywhere if we refactor - // the `test.*` operations so they don't wait until the Simulator - // instance is ready. - false: splitLink({ - condition(op) { - return op.path.startsWith("test."); - }, - true: httpLink({ - url: trpcUrl, - }), - false: httpBatchLink({ - url: trpcUrl, - }), + false: unstable_httpBatchStreamLink({ + url: trpcUrl, }), }), ],