Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(console): use http batch streams #7051

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 3 additions & 23 deletions apps/wing-console/console/ui/src/Console.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -61,34 +60,15 @@ export const Console = ({
const [trpcClient] = useState(() =>
trpc.createClient({
links: [
// For subscriptions, use WebSocket.
splitLink({
condition(op) {
return op.type === "subscription";
},
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({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

url: trpcUrl,
}),
}),
],
Expand Down