Abhishek
Abhishek
CCConvex Community
Created by Abhishek on 7/11/2024 in #support-community
Rate Limiting Options
would love to be able to set custom rate limits for the actions, queries, mutations, and actions. it would be nice to manually add IP addresses to block, block by country, query depth limits, etc.
7 replies
CCConvex Community
Created by Abhishek on 6/25/2024 in #support-community
Issue with deployment
Detected a non-production build environment and "CONVEX_DEPLOY_KEY" for a production Convex deployment. This is probably unintentional.
Error: Command "npx convex deploy --cmd 'npm run build'" exited with 1
7 replies
CCConvex Community
Created by Abhishek on 6/20/2024 in #support-community
ts error help
Error : 'campaign' is referenced directly or indirectly in its own type annotation. In my utils.ts if i add one more export function then this error is being given by ts but if there is only one export function then there is no ts error
20 replies
CCConvex Community
Created by Abhishek on 6/20/2024 in #support-community
date-fns-tz support ?
I have util function which uses date-fns-tz or date-fns library which is called inside a mutation does convex not support this lib ? as im getting this error
Uncaught Error: `new Date()` with non-number arguments is not supported.
at getDateTimeFormat (../../node_modules/date-fns-tz/esm/_lib/tzTokenizeDate/index.js:64:6)
at tzTokenizeDate (../../node_modules/date-fns-tz/esm/_lib/tzTokenizeDate/index.js:6:13)
at calcOffset (../../node_modules/date-fns-tz/esm/_lib/tzParseTimezone/index.js:88:14)
at tzParseTimezone (../../node_modules/date-fns-tz/esm/_lib/tzParseTimezone/index.js:64:8)
at zonedTimeToUtc (../../node_modules/date-fns-tz/esm/zonedTimeToUtc/index.js:51:24)
at checkIfCampaignIsInPast (../../convex/utils.ts:12:6)
at handler (../convex/linkedin.ts:62:48)
Uncaught Error: `new Date()` with non-number arguments is not supported.
at getDateTimeFormat (../../node_modules/date-fns-tz/esm/_lib/tzTokenizeDate/index.js:64:6)
at tzTokenizeDate (../../node_modules/date-fns-tz/esm/_lib/tzTokenizeDate/index.js:6:13)
at calcOffset (../../node_modules/date-fns-tz/esm/_lib/tzParseTimezone/index.js:88:14)
at tzParseTimezone (../../node_modules/date-fns-tz/esm/_lib/tzParseTimezone/index.js:64:8)
at zonedTimeToUtc (../../node_modules/date-fns-tz/esm/zonedTimeToUtc/index.js:51:24)
at checkIfCampaignIsInPast (../../convex/utils.ts:12:6)
at handler (../convex/linkedin.ts:62:48)
The same util function is working fine in the frontend of nextjs
3 replies
CCConvex Community
Created by Abhishek on 6/19/2024 in #support-community
Need suggestion on how to store user
I followed the SASS starter approach of storing user in database through useEffect inside a provider component. But I am having this race condition where the provider renders a child which is a server component that require user to be in DB and its throwing error as we are storing user through client component provider. To solve this to make the child a client component but I wanted to ask is there any other way to go around this ? Like calling store user through server component but then how to condition it so that its not called everytime Provider Component
<ConvexProviderWithClerk client={convex} useAuth={useAuth}>
<Authenticated>
<StoreUserInDatabase />
{children}
</Authenticated>
<AuthLoading>
<Loading />
</AuthLoading>
</ConvexProviderWithClerk>

function StoreUserInDatabase() {
const { user } = useUser();
const storeUser = useMutation(api.users.store);
useEffect(() => {
void storeUser();
}, [storeUser, user?.id]);
return null;
}
<ConvexProviderWithClerk client={convex} useAuth={useAuth}>
<Authenticated>
<StoreUserInDatabase />
{children}
</Authenticated>
<AuthLoading>
<Loading />
</AuthLoading>
</ConvexProviderWithClerk>

function StoreUserInDatabase() {
const { user } = useUser();
const storeUser = useMutation(api.users.store);
useEffect(() => {
void storeUser();
}, [storeUser, user?.id]);
return null;
}
8 replies
CCConvex Community
Created by Abhishek on 6/18/2024 in #support-community
Logs are different for dev and prod
I am experiencing a bug related to the new Date () but the issue is logs are not at all showing in dev env but the error log is showing in prod.
export function convertTimeToUTC(
startDate: string,
time: string,
timezone: string,
) {
const formatString = "yyyy-MM-dd hh:mm a";

const parsedTime = parse(time, "h:mm a", new Date());
const formattedTime = format(parsedTime, "HH:mm:ss");

console.debug(
"API Logs | Time and start date and timezon of the user: ",
time,
startDate,
timezone,
);

const parsedDate = parse(
`${startDate} ${time}`,
formatString,
new Date(),
).toLocaleString();

console.log("API Logs | Parsed time and start date : ", parsedDate);
try {
const utcTime = zonedTimeToUtc(`${startDate} ${formattedTime}`, timezone);
console.log("API Logs | Time in UTC : ", utcTime.toLocaleString());
console.log("API Logs | Time in UTC sent to cron : ", utcTime);
return utcTime;
} catch (error) {
console.error("API Logs | Error in converting time to UTC", error);
}
}
export function convertTimeToUTC(
startDate: string,
time: string,
timezone: string,
) {
const formatString = "yyyy-MM-dd hh:mm a";

const parsedTime = parse(time, "h:mm a", new Date());
const formattedTime = format(parsedTime, "HH:mm:ss");

console.debug(
"API Logs | Time and start date and timezon of the user: ",
time,
startDate,
timezone,
);

const parsedDate = parse(
`${startDate} ${time}`,
formatString,
new Date(),
).toLocaleString();

console.log("API Logs | Parsed time and start date : ", parsedDate);
try {
const utcTime = zonedTimeToUtc(`${startDate} ${formattedTime}`, timezone);
console.log("API Logs | Time in UTC : ", utcTime.toLocaleString());
console.log("API Logs | Time in UTC sent to cron : ", utcTime);
return utcTime;
} catch (error) {
console.error("API Logs | Error in converting time to UTC", error);
}
}
So this function is throwing an error but the error is not coming in dev environments logs but showing up in prod logs
34 replies
CCConvex Community
Created by Abhishek on 5/23/2024 in #support-community
Transient error while executing action
No description
4 replies
CCConvex Community
Created by Abhishek on 4/24/2024 in #support-community
Convex and nextjs , docker hosting possible ?
Is it possible to build a docker image of nextjs with convex and host it on vps ? I am tring to move away from vercel and thinking of buying vps and using https://coolify.io/
9 replies
CCConvex Community
Created by Abhishek on 4/6/2024 in #support-community
Need help with building a Scheduler app
I need some advice on how can we do this, I am building a social media schedule app where users can select their timezone, date range and at what time to post on social media. For example - If I chose to run the scheduler for 3 days ie (7-10) at the same time 5 pm then for these days on 5pm the post will be published Could anyone give me an overview of how can we build this? Thanks
11 replies
CCConvex Community
Created by Abhishek on 4/4/2024 in #support-community
internal action not showing arguments
No description
15 replies
CCConvex Community
Created by Abhishek on 3/21/2024 in #support-community
Use Query needs additional functions
I need help with this, how do we know the use query value is not changing anymore? Maybe an additional hook with useQuery so an event is fired when there are no changes. Currently, I am streaming the response storing it in DB and using query to show on the frontend I want to render a button when a response is complete so for this case I am not able to figure out how can we handle this.
6 replies
CCConvex Community
Created by Abhishek on 3/16/2024 in #support-community
Anthropic SDK with Convex | Claude AI
I was trying to run the anthropic SDK in action and trying to get a streaming response. When I am trying to run the action from the dashboard then the response is not at all coming up. Here is my action code :
export const generatePostGeneration = action({
args: {
userInput: v.string(),
},
async handler(ctx, args) {
const client = new Anthropic({
apiKey:""
});
let body = "";
try {
await client.messages
.stream({
messages: [{ role: "user", content: "Hello" }],
model: "claude-3-sonnet-20240229",
max_tokens: 1024,
})
.on("text", (text: any) => {
body += text;
console.log("Stream:", text);
});
} catch (error) {
console.log("Error:", error);
}
console.log("Body:", body);
return body;
},
});
export const generatePostGeneration = action({
args: {
userInput: v.string(),
},
async handler(ctx, args) {
const client = new Anthropic({
apiKey:""
});
let body = "";
try {
await client.messages
.stream({
messages: [{ role: "user", content: "Hello" }],
model: "claude-3-sonnet-20240229",
max_tokens: 1024,
})
.on("text", (text: any) => {
body += text;
console.log("Stream:", text);
});
} catch (error) {
console.log("Error:", error);
}
console.log("Body:", body);
return body;
},
});
This is only happening for streaming for normal messages I am getting the response. anthropic docs: https://docs.anthropic.com/claude/reference/messages-streaming
29 replies
CCConvex Community
Created by Abhishek on 3/4/2024 in #support-community
React Suspense is not working up with convex
I wrapped my client parent component with suspense, the parent client component is using useQuery hook and and based on state the query is changing. I want to ask am I doing it in a wrong way cuz my suspense fallback is clearing not showing up This how i am wrapping my parent component
<main className="flex min-h-screen flex-col items-center">
<TrendingSection />
<Suspense
fallback={<div className="h-40 w-40 bg-slate-400">Loading...</div>}
>
<WeekHeader />
</Suspense>
</main>
<main className="flex min-h-screen flex-col items-center">
<TrendingSection />
<Suspense
fallback={<div className="h-40 w-40 bg-slate-400">Loading...</div>}
>
<WeekHeader />
</Suspense>
</main>
7 replies
CCConvex Community
Created by Abhishek on 2/29/2024 in #support-community
How to extract types from schema if possible ?
export const getTrendingComics = query({
args: { id: v.string() },
handler: async (ctx) => {
const trendingComicsData: any = [];
const webData = await ctx.db.query("websiteContent").first();
const trendingComicsIdArray = webData?.trendingComics;
if (trendingComicsIdArray) {
await Promise.all(
trendingComicsIdArray.map(async (id) => {
const comic = await ctx.db.get(id);
trendingComicsData.push(comic);
})
);
}

return trendingComicsData;
},
});
export const getTrendingComics = query({
args: { id: v.string() },
handler: async (ctx) => {
const trendingComicsData: any = [];
const webData = await ctx.db.query("websiteContent").first();
const trendingComicsIdArray = webData?.trendingComics;
if (trendingComicsIdArray) {
await Promise.all(
trendingComicsIdArray.map(async (id) => {
const comic = await ctx.db.get(id);
trendingComicsData.push(comic);
})
);
}

return trendingComicsData;
},
});
How can I get the type of trendingComicsData from the schema ?
9 replies
CCConvex Community
Created by Abhishek on 2/27/2024 in #support-community
Alternate hosting options ?
Hi, I am pretty noob with infra part of software engineering. But I wanted to ask apart from vercel and netlify can convex support hosting on other platforms like railway, render for nextjs and convex app ? thanks
28 replies
CCConvex Community
Created by Abhishek on 2/26/2024 in #support-community
Convex's self auth system
Currently, I am converting all my client projects from Supabase to Convex and for all the new clients I am directly asking them to give Convex a chance. But the clients are only hesitant majorly about one thing that I have noticed : Is the Costing They don't want to pay separately for backend and authentication and want a single-stop solution that includes both auth and backend together. So I request the Convex team to think about this and in future add Convex self-auth system
19 replies
CCConvex Community
Created by Abhishek on 2/25/2024 in #support-community
useQuery and fetchQuery are cached?
Just like in nextjs 14 fetch automatically caches the response of same api does same thing happens with useQuery and fetchQuery in convex ?
7 replies
CCConvex Community
Created by Abhishek on 2/24/2024 in #support-community
document id as pathname
So I'm using the document ID as a pathname, which is making url ugly and too long is there any alternate approach that I can use? So it's like for example -> abc/[document_id] and when someone goes to abc/[document_id] through the document id I am getting the info to show it on the page. Can someone please suggest an alternative approach to this thanks
5 replies
CCConvex Community
Created by Abhishek on 2/20/2024 in #support-community
Why my Convex simple query is taking too long?
No description
28 replies
CCConvex Community
Created by Abhishek on 2/7/2024 in #support-community
getUserIdentity() resulting none
So I am calling http action from a 3rd party service in my case LinkedIn and following there 3 steps legged oauth. But while calling
const identity = await ctx.auth.getUserIdentity();
console.log(
"Response Data--------XXXXXXXXXX----->",
JSON.stringify(identity)
);
const identity = await ctx.auth.getUserIdentity();
console.log(
"Response Data--------XXXXXXXXXX----->",
JSON.stringify(identity)
);
Identity is returning null, how can I authenticate in this scenario? Sharing my full code for more ref : https://github.com/imaxisXD/AIvy-Post/blob/main/convex/oauth.ts
20 replies