Odiel
Odielā€¢2mo ago

What is wrong with my subscription setup?

Hi, I'm new to trpc and while playing with subscriptions for some reason I can't make it work. In this gist (https://gist.github.com/odiel/f4d3d09650fd1598ea29f6750e76841a) I have the server and client setup. I'm using the latest Deno version and "@trpc/server": "npm:@trpc/server@^11.0.0-rc.638", "@trpc/client": "npm:@trpc/client@^11.0.0-rc.638",. Once running the client it stays in, and I don't get to see any of the events emitted on the backend reaching the client. What am I doing wrong?
<< subscription #1 example {
input: undefined,
result: { result: { type: "state", state: "pending", error: null } },
elapsedMs: 139243
}
<< subscription #1 example {
input: undefined,
result: { result: { type: "state", state: "pending", error: null } },
elapsedMs: 139243
}
Gist
client.txt
GitHub Gist: instantly share code, notes, and snippets.
4 Replies
P.S.Nikhil
P.S.Nikhilā€¢5w ago
find any solution ?
Odiel
OdielOPā€¢5w ago
nope šŸ˜¦
BeBoRE
BeBoREā€¢5w ago
What does your dev console say? In the network tab?
Odiel
OdielOPā€¢4w ago
I ran this from the CLI not the browser
> deno run -A .\src\client.ts
>> subscription #1 example { input: undefined }
<< subscription #1 example {
input: undefined,
result: { result: { type: "state", state: "connecting", error: null } },
elapsedMs: 1
}
šŸ‘Œ should be a clean exit if everything is working right
> deno run -A .\src\client.ts
>> subscription #1 example { input: undefined }
<< subscription #1 example {
input: undefined,
result: { result: { type: "state", state: "connecting", error: null } },
elapsedMs: 1
}
šŸ‘Œ should be a clean exit if everything is working right
this is the client output nothing else happens after that found a solution looking at Deno blog https://deno.com/blog/build-typesafe-apis-trpc, importing
import { createHTTPServer } from "@trpc/server/adapters/standalone";
import { createHTTPServer } from "@trpc/server/adapters/standalone";
solved the problem

Did you find this page helpful?