MrJohz
MrJohz
Explore posts from servers
TtRPC
Created by MrJohz on 4/8/2025 in #❓-help
How can I access the session in fastify when using `useWSS: true`?
I've got a fastify/trpc application that looks something like this:
await using app = Fastify({
loggerInstance: logger,
bodyLimit: 5 * 1024 * 1024,
https: stores.config.sslOptions ?? null,
maxParamLength: 5000,
});

app.register(ws);
app.register(fastifyCookie);
app.register(fastifySession, {
secret: "super secret, don't look at me",
});

function createContext({ req }: CreateFastifyContextOptions) {
console.log(req.session); // logs "undefined"
return {};
}

app.register(fastifyTRPCPlugin, {
prefix: "/trpc",
useWSS: true,
keepAlive: { enabled: true, pingMs: 50 * 1000 },
trpcOptions: { router, onError, createContext },
});
await using app = Fastify({
loggerInstance: logger,
bodyLimit: 5 * 1024 * 1024,
https: stores.config.sslOptions ?? null,
maxParamLength: 5000,
});

app.register(ws);
app.register(fastifyCookie);
app.register(fastifySession, {
secret: "super secret, don't look at me",
});

function createContext({ req }: CreateFastifyContextOptions) {
console.log(req.session); // logs "undefined"
return {};
}

app.register(fastifyTRPCPlugin, {
prefix: "/trpc",
useWSS: true,
keepAlive: { enabled: true, pingMs: 50 * 1000 },
trpcOptions: { router, onError, createContext },
});
I would expect that the req in the createContext function would have access to the session (and it does if useWSS is false). However, when using TRPC with websockets, it currently consistently logs undefined. I assume this is because I'm misconfiguring something somewhere, but I'm not sure what, and I'm not sure how to solve this. Has anyone experienced this, or does anyone have any suggestions about how to resolve this? Thanks in advance!
7 replies
SSolidJS
Created by MrJohz on 1/23/2025 in #support
How can I test that all computations were created in a root?
I have a complicated hook that creates a bunch of memos and other signals that have a somewhat complex lifecycle. I have tests that check that the behaviour is correct, but usually the clearest way I see that something's gone wrong is if warnings show up in the test messages. Is there a way that I can check that all computations were created in a root, and if possible, can I check that they were created in a particular root and therefore cleaned up when that root is disposed?
5 replies