welp
welp
TtRPC
Created by welp on 8/28/2023 in #❓-help
Configuration help
Explicitly specifying logic on useQuery({}, { refetchOnWindowFocus: false, }) is sufficient enough.
4 replies
TtRPC
Created by welp on 8/28/2023 in #❓-help
Configuration help
I found this: https://github.com/trpc/trpc/issues/3684 But I am confused on how to pursue this in a websocket tRPC context.
4 replies
TtRPC
Created by welp on 6/2/2023 in #❓-help
Is it possible to create 2 routers inside a single file?
Yeah I don't know, I implemented redis and everything is working properly.
8 replies
TtRPC
Created by welp on 6/2/2023 in #❓-help
Is it possible to create 2 routers inside a single file?
@Nick Lucas I am trying to use a singleton class instance which is storing a hash map of eventemitter objects which I want to use for subscriptions. What happens specifically is that when I emit an event, it is emitted on an instance that has no callbacks registered. This is due to the next bug, re-evaluating an import from an external file and replacing its pointer in memory with a newly empty created instance. The way I tried to avoid this, since I want to use that class instance in 2 routers, I tried to create my 2 routers inside a single file, declare the class instance in there and move on, but didn't work. I didn't try to merge the 2 routers into 1 however, I will do that tomorrow and get back to you.
8 replies
TtRPC
Created by DevR on 5/28/2023 in #❓-help
Next-auth session not being fetched in tRPC context
OS maybe has something to do with this, I am on: Ubuntu 20.04.6 LTS
20 replies
TtRPC
Created by DevR on 5/28/2023 in #❓-help
Next-auth session not being fetched in tRPC context
very strange indeed... I just don't get it how the websockets-starter is so functional with just the getSession() utility
20 replies
TtRPC
Created by DevR on 5/28/2023 in #❓-help
Next-auth session not being fetched in tRPC context
But the functionality was pretty much working no problem.
20 replies
TtRPC
Created by DevR on 5/28/2023 in #❓-help
Next-auth session not being fetched in tRPC context
I also jsut downloaded the websockets-starter example and the only error I got (not using the mocked edition) was:
[next-auth][error][JWT_SESSION_ERROR]
https://next-auth.js.org/errors#jwt_session_error decryption operation failed
[next-auth][error][JWT_SESSION_ERROR]
https://next-auth.js.org/errors#jwt_session_error decryption operation failed
20 replies
TtRPC
Created by DevR on 5/28/2023 in #❓-help
Next-auth session not being fetched in tRPC context
Hey, this is how I bypassed this issue, although I still get null tokens/sessions when I am not supposed to, it functions overall:
export const createTRPCContext = async (
opts:
| CreateNextContextOptions
| NodeHTTPCreateContextFnOptions<IncomingMessage, ws>
// eslint-disable-next-line @typescript-eslint/require-await
) => {
const { req, res } = opts;
if (typeof (res as any).getHeaders !== "function") {
const token = await getToken({
req: req as any,
secret: process.env.NEXTAUTH_SECRET,
});

if (token) {
// console.log("Got JWT token:", token);
return { session: { user: token } };
}

console.log("null token");

const session = await getSession(opts);

if (session) {
return { session };
}

console.log("null getSession");

return { session: null };
}

const session = await getServerSession(req as any, res as any, authOptions);

if (session) {
return { session };
}
console.log("null session");
return { session: null };
};
export const createTRPCContext = async (
opts:
| CreateNextContextOptions
| NodeHTTPCreateContextFnOptions<IncomingMessage, ws>
// eslint-disable-next-line @typescript-eslint/require-await
) => {
const { req, res } = opts;
if (typeof (res as any).getHeaders !== "function") {
const token = await getToken({
req: req as any,
secret: process.env.NEXTAUTH_SECRET,
});

if (token) {
// console.log("Got JWT token:", token);
return { session: { user: token } };
}

console.log("null token");

const session = await getSession(opts);

if (session) {
return { session };
}

console.log("null getSession");

return { session: null };
}

const session = await getServerSession(req as any, res as any, authOptions);

if (session) {
return { session };
}
console.log("null session");
return { session: null };
};
20 replies
TtRPC
Created by welp on 5/30/2023 in #❓-help
Initial websockets getToken() returns null: next-auth + websockets :)
I got it working! I still get null sessions but now I do eventually get the session needed for a subscription to be possible! Working code is the following:
export const createTRPCContext = async (
opts:
| CreateNextContextOptions
| NodeHTTPCreateContextFnOptions<IncomingMessage, ws>
// eslint-disable-next-line @typescript-eslint/require-await
) => {
const { req, res } = opts;
if (typeof (res as any).getHeaders !== "function") {
const token = await getToken({
req: req as any,
secret: process.env.NEXTAUTH_SECRET,
});

if (token) {
// console.log("Got JWT token:", token);
return { session: { user: token } };
}

console.log("null token");

const session = await getSession(opts);

if (session) {
return { session };
}

console.log("null getSession");

return { session: null };
}

const session = await getServerSession(req as any, res as any, authOptions);

if (session) {
return { session };
}
console.log("null session");
return { session: null };
};
export const createTRPCContext = async (
opts:
| CreateNextContextOptions
| NodeHTTPCreateContextFnOptions<IncomingMessage, ws>
// eslint-disable-next-line @typescript-eslint/require-await
) => {
const { req, res } = opts;
if (typeof (res as any).getHeaders !== "function") {
const token = await getToken({
req: req as any,
secret: process.env.NEXTAUTH_SECRET,
});

if (token) {
// console.log("Got JWT token:", token);
return { session: { user: token } };
}

console.log("null token");

const session = await getSession(opts);

if (session) {
return { session };
}

console.log("null getSession");

return { session: null };
}

const session = await getServerSession(req as any, res as any, authOptions);

if (session) {
return { session };
}
console.log("null session");
return { session: null };
};
5 replies
TtRPC
Created by welp on 5/30/2023 in #❓-help
Initial websockets getToken() returns null: next-auth + websockets :)
Eventually I came with this which doesn't resolve anything as the token comes up null:
export const createTRPCContext = async (
opts:
| CreateNextContextOptions
| NodeHTTPCreateContextFnOptions<IncomingMessage, ws>
// eslint-disable-next-line @typescript-eslint/require-await
) => {
const { req, res } = opts;
if (typeof (res as any).getHeaders !== "function") {
const token = await getToken({
req: req as any,
secret: process.env.NEXTAUTH_SECRET,
});

if (token) {
// console.log("Got JWT token:", token);
return { session: { user: token } };
}

console.log("null token");
return { session: null };
}

const session = await getServerSession(req as any, res as any, authOptions);

if (session) {
return { session };
}
console.log("null session");
return { session: null };
};
export const createTRPCContext = async (
opts:
| CreateNextContextOptions
| NodeHTTPCreateContextFnOptions<IncomingMessage, ws>
// eslint-disable-next-line @typescript-eslint/require-await
) => {
const { req, res } = opts;
if (typeof (res as any).getHeaders !== "function") {
const token = await getToken({
req: req as any,
secret: process.env.NEXTAUTH_SECRET,
});

if (token) {
// console.log("Got JWT token:", token);
return { session: { user: token } };
}

console.log("null token");
return { session: null };
}

const session = await getServerSession(req as any, res as any, authOptions);

if (session) {
return { session };
}
console.log("null session");
return { session: null };
};
5 replies
TtRPC
Created by welp on 5/30/2023 in #❓-help
Initial websockets getToken() returns null: next-auth + websockets :)
I also tried with handling auth with const session = await getServerSession(req as any, res as any, authOptions); however I run into the following error: res.getHeader is not a function
5 replies
TtRPC
Created by welp on 5/5/2023 in #❓-help
Error: No QueryClient set, use QueryClientProvider to set one
Adding this as a dependency resolved the issue inside package.json: "@tanstack/react-query": "^4.20.4",
8 replies