oscklm
oscklm
CCConvex Community
Created by oscklm on 12/5/2024 in #support-community
Convex-helpers zod.ts typescript error caught by npx tsc
No description
1 replies
CCConvex Community
Created by oscklm on 11/22/2024 in #support-community
Issue with convex being picked up by `npx tsc` in expo project
Hello, was hoping some typescript wizard could help me out here. I've been trying to configure my repos tsconfig to not clash with the tsconfig.json in our convex/ folder. The problem Whenever i run npx tsc to check for any typescript compile errors from the root of my repo, it picks up on some files in my projects from the convex/ and says there are errors.
Found 15 errors in 6 files.

Errors Files
1 convex/activity/mutations.ts:68
2 convex/auth/CustomPassword.tsx:1
5 convex/auth/resend/PasswordResetConfig.tsx:1
5 convex/auth/resend/VerifyEmailConfig.tsx:1
1 convex/core/migrations.ts:47
1 node_modules/convex-helpers/server/zod.ts:443
Found 15 errors in 6 files.

Errors Files
1 convex/activity/mutations.ts:68
2 convex/auth/CustomPassword.tsx:1
5 convex/auth/resend/PasswordResetConfig.tsx:1
5 convex/auth/resend/VerifyEmailConfig.tsx:1
1 convex/core/migrations.ts:47
1 node_modules/convex-helpers/server/zod.ts:443
But convex/ has its own tsconfig (the default one from convex), and when running npx tsc if i cd into the convex folder, i get none of those errors as stated above. So only running tsc in the root says errors are present in a few convex folder files. I'm using this tsconfig, since im in a expo project:
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true,
"skipLibCheck": true,
"paths": {
"@/*": ["./*"]
},
"moduleSuffixes": [".ios", ".android", ".native", ""]
},
"exclude": ["convex/**/*"],
"include": ["**/*.tsx", "**/*.ts", ".expo/types/**/*.ts", "expo-env.d.ts", "vitest.config.mts"]
}
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true,
"skipLibCheck": true,
"paths": {
"@/*": ["./*"]
},
"moduleSuffixes": [".ios", ".android", ".native", ""]
},
"exclude": ["convex/**/*"],
"include": ["**/*.tsx", "**/*.ts", ".expo/types/**/*.ts", "expo-env.d.ts", "vitest.config.mts"]
}
I've tried a few things: - Removed the "**/*.tsx", "**/*.ts" from the include, as i thought maybe those were overwriting the exclude i added, but that messed all my path imports up in my project. - Playing around with multiple different glob patterns for the excludes, but without luck - Tried setting up a reference in the root tsconfig to the one in convex/ but that didn't work out due to "noEmit": true in the convex tsconfig
21 replies
CCConvex Community
Created by oscklm on 9/22/2024 in #support-community
Designing a friend system with Convex
Hi, I’m building a friend system with Convex and am torn between two approaches: 1. Multiple indexes for better scalability. 2. Multiple entries in a single table for each friendship. I’ve implemented lexicographical sorting for user1 and user2 when inserting friendships, but when querying friendships for a user, the following approach is limited by the compound index:
const friendshipsAsUser1 = await ctx.db
.query('userFriend')
.withIndex('by_userIds', (q) => q.eq('user1', userId))
.collect();

const friendshipsAsUser2 = await ctx.db
.query('userFriend')
.withIndex('by_userIds', (q) => q.eq('user2', userId))
.collect();
const friendshipsAsUser1 = await ctx.db
.query('userFriend')
.withIndex('by_userIds', (q) => q.eq('user1', userId))
.collect();

const friendshipsAsUser2 = await ctx.db
.query('userFriend')
.withIndex('by_userIds', (q) => q.eq('user2', userId))
.collect();
The problem is that compound indexes require the query order to match the order in which the fields were indexed (e.g., ['user1', 'user2']), which limits flexibility in querying. I’ve come up with a solution where id just do multiple entries, 1 for each side of the friendship, but I’m concerned about scalability. Is there a better way to handle this without creating multiple entries for each friendship or excessive indexes? I'm very curious how to tackle this, specifically if there is any way that goes great with Convex?
4 replies
CCConvex Community
Created by oscklm on 9/17/2024 in #support-community
using _storageId vs storing storage urls directly
How stable are the generated file storage URL´s, and could we rather than storing the _storage id field, just store the file storage URL from the start, like when a document is created and the file uploaded? Asking this because, im wondering if we could simplify a bunch of enrichments we are doing when querying documents, and their related data?
24 replies
CCConvex Community
Created by oscklm on 9/13/2024 in #support-community
Require cycle issues, can't seem to troubleshoot to where its coming from
Hello, I'm getting this error when starting my expo web server. And have tried troubleshooting it for a while now, but can't seem to find any place where this import cycle happens that has anything to do with the files mentioned in the error: Can anyone from the convex team, help me shine some light on this and where i could maybe look and check?
λ WARN Require cycle: node_modules/convex/dist/cjs/server/impl/actions_impl.js -> node_modules/convex/dist/cjs/server/api.js -> node_modules/convex/dist/cjs/server/impl/actions_impl.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
factory (node_modules/convex/dist/cjs/server/api.js:35:27)
factory (node_modules/convex/dist/cjs/server/impl/actions_impl.js:29:18)
λ WARN Require cycle: node_modules/convex/dist/cjs/server/impl/actions_impl.js -> node_modules/convex/dist/cjs/server/api.js -> node_modules/convex/dist/cjs/server/impl/actions_impl.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
factory (node_modules/convex/dist/cjs/server/api.js:35:27)
factory (node_modules/convex/dist/cjs/server/impl/actions_impl.js:29:18)
3 replies
CCConvex Community
Created by oscklm on 9/10/2024 in #support-community
Issue with expo app and convex, and how .env variables are loaded
Is there a way to have convex read .env.development rather than the default .env.local The reason for asking is that i am using convex in a expo app where i store some production variables in a .env.production which i use for testing the app against my prod convex deployment. When i run yarn dev --no-dev --minify expo dev server loads the envs from .env.local and .env.production but that seems to end up with the production envs being overwritten by the ones in the .local So i therefore can't seem to test my convex prod env against my expo app, without manually replacing the .env.local variables. Any recommendations on what to do here for a better dev experience?
1 replies
CCConvex Community
Created by oscklm on 9/10/2024 in #support-community
[ConvexAuth] stuck on auth loading & websocket reconnect
Hello, We are experiencing some issues with the @convex-dev/auth library it seems We are using these versions of the related packages: @convex-dev/auth@0.0.65 convex@1.15.0 When we sign in or sign up a user, the useConvexAuth() doesnt pickup the change it seems, and we are stuck with a isLoading being true and get the WebSocket reconnect logged in console below, until we use signOut() from useAuthActions()`
Attempting reconnect in 146.84511437432195ms
LOG WebSocket reconnected
LOG Attempting reconnect in 274.0716054331094ms
LOG WebSocket reconnected
LOG Attempting reconnect in 519.5632832559711ms
LOG WebSocket reconnected
Attempting reconnect in 146.84511437432195ms
LOG WebSocket reconnected
LOG Attempting reconnect in 274.0716054331094ms
LOG WebSocket reconnected
LOG Attempting reconnect in 519.5632832559711ms
LOG WebSocket reconnected
We've made a repro available here, which isolates the issue: https://github.com/oscklm/flimmer-auth-issue We've troubleshooted and tried a bunch of different approaches: - yarn clean cache, remove node_modules, delete yarn lock - we tried setting up a repro, and removing pretty much everything but auth
9 replies
CCConvex Community
Created by oscklm on 9/5/2024 in #support-community
Verifying JWS Signed Payload in Convex httpAction
I am currently working on verifying an Apple App Store notification's signed payload using a public key within a Convex httpAction. Below is a snippet of the code I am using:
import jwt from 'jsonwebtoken';
import { httpAction } from '../_generated/server';

export const proccessAppStoreNotifications = httpAction(async (ctx, req) => {
const {signedPayload, unified_receipt} = await req.json();


// Check for signedPayload (version 2 notifications)
if (signedPayload) {
console.log('signed Payload:', signedPayload);

// Load the public key from a secure location or environment variable
const publicKey = process.env.APPLE_PUBLIC_KEY;

if (!publicKey) {
throw new Error('Public key not configured');
}

try {
// Verify the JWS signedPayload using Apple's public key
const payload = jwt.verify(signedPayload, publicKey);

// Perform your business logic here, such as updating user subscriptions, etc.
return new Response('Subscription update handled in convex', { status: 200 });
} catch (error) {
console.error('Error verifying JWS:', error);
return new Response('Invalid signature', { status: 400 });
}
}
return new Response('Invalid notification format', { status: 400 });
});
import jwt from 'jsonwebtoken';
import { httpAction } from '../_generated/server';

export const proccessAppStoreNotifications = httpAction(async (ctx, req) => {
const {signedPayload, unified_receipt} = await req.json();


// Check for signedPayload (version 2 notifications)
if (signedPayload) {
console.log('signed Payload:', signedPayload);

// Load the public key from a secure location or environment variable
const publicKey = process.env.APPLE_PUBLIC_KEY;

if (!publicKey) {
throw new Error('Public key not configured');
}

try {
// Verify the JWS signedPayload using Apple's public key
const payload = jwt.verify(signedPayload, publicKey);

// Perform your business logic here, such as updating user subscriptions, etc.
return new Response('Subscription update handled in convex', { status: 200 });
} catch (error) {
console.error('Error verifying JWS:', error);
return new Response('Invalid signature', { status: 400 });
}
}
return new Response('Invalid notification format', { status: 400 });
});
I am unable to use the jsonwebtoken library directly in the code to verify the JWS signed payload. Could you please provide a different recommended approach for verifying JWS signed payloads in this httpAction context? Thanks!
2 replies
CCConvex Community
Created by oscklm on 8/26/2024 in #support-community
[ConvexAuth]: Handling errors that happen from the useAuthActions methods
No description
2 replies
CCConvex Community
Created by oscklm on 8/8/2024 in #support-community
[ConvexAuth] Convex 1.14 seems to break ConvexAuthProvider token storage
Just had a issue where tokens weren't picked up by ConvexAuthProvider, after upgrading to Convex 1.14, going back to 1.13.2 fixed the issue, and saved jwt tokens were loaded as expected. Let me know if more info is needed
9 replies
CCConvex Community
Created by oscklm on 8/6/2024 in #support-community
[ConvexAuth]: ERROR Auth token is not a valid JWT, cannot refetch the token
Hey, I'm using ConvexAuth in app, and specifically, using the password-code from the convex auth demo repo, i'm able to successfully sign up and verify with my email code. And also able to login when using the password-code provider and flow signIn But upon being signed in, i get the following error: ERROR Auth token is not a valid JWT, cannot refetch the token convex/auth.ts
import { Password } from '@convex-dev/auth/providers/Password';
import { convexAuth } from '@convex-dev/auth/server';
import { ResendOTPPasswordReset } from '../resend/PasswordReset/ResendOTPPasswordReset';
import { ResendOTP } from '../resend/ResendOTP';

export const { auth, signIn, signOut, store } = convexAuth({
providers: [
Password({
id: 'password-code',
reset: ResendOTPPasswordReset,
verify: ResendOTP,
}),
],
callbacks: {
async afterUserCreatedOrUpdated(ctx, { userId }) {
if (!userId) return;
await ctx.db.patch(userId, {
role: 'user',
});
},
},
session: {
totalDurationMs: 1000 * 60 * 60 * 24 * 30, // 90 days
inactiveDurationMs: 1000 * 60 * 60 * 24 * 7, // 7 days
},
});
import { Password } from '@convex-dev/auth/providers/Password';
import { convexAuth } from '@convex-dev/auth/server';
import { ResendOTPPasswordReset } from '../resend/PasswordReset/ResendOTPPasswordReset';
import { ResendOTP } from '../resend/ResendOTP';

export const { auth, signIn, signOut, store } = convexAuth({
providers: [
Password({
id: 'password-code',
reset: ResendOTPPasswordReset,
verify: ResendOTP,
}),
],
callbacks: {
async afterUserCreatedOrUpdated(ctx, { userId }) {
if (!userId) return;
await ctx.db.patch(userId, {
role: 'user',
});
},
},
session: {
totalDurationMs: 1000 * 60 * 60 * 24 * 30, // 90 days
inactiveDurationMs: 1000 * 60 * 60 * 24 * 7, // 7 days
},
});
SignInScreen.tsx
export const SignInScreen = () => {
//...
const { signIn } = useAuthActions();

const handleLogin = async (values: SignInFormValues) => {
try {
await signIn('password-code', {
flow: 'signIn',
email: values.email,
password: values.password,
});
router.back();
} catch (error) {
console.log(error);
}
};

//...
};
export const SignInScreen = () => {
//...
const { signIn } = useAuthActions();

const handleLogin = async (values: SignInFormValues) => {
try {
await signIn('password-code', {
flow: 'signIn',
email: values.email,
password: values.password,
});
router.back();
} catch (error) {
console.log(error);
}
};

//...
};
4 replies
CCConvex Community
Created by oscklm on 8/6/2024 in #support-community
[ConvexAuth]: additional fields passed to signIn, added to user document?
Hello, Is there a way to pass additional sign up values passed to signIn from useAuthActions like for example, here when i sign up my user, i let them define a name in my signup component.
await signIn('password', {
flow: 'signUp',
email: trimmedEmail,
password: trimmedPassword,
name: trimmedName,
});
await signIn('password', {
flow: 'signUp',
email: trimmedEmail,
password: trimmedPassword,
name: trimmedName,
});
I'm unsure where to get the name from, since its not passed to args.profile etc?
export const { auth, signIn, signOut, store } = convexAuth({
providers: [
Password,
],
callbacks: {
async createOrUpdateUser(ctx, args) {
if (args.existingUserId) {
await ctx.db.patch(args.existingUserId, {
email: args.profile.email,
phone: args.profile.phone,
// Name goes here
});
return args.existingUserId;
} else {
return await ctx.db.insert('users', {
role: 'user',
email: args.profile.email,
// Name goes here
});
}
},
},
session: {
totalDurationMs: 1000 * 60 * 60 * 24 * 30, // 90 days
inactiveDurationMs: 1000 * 60 * 60 * 24 * 7, // 7 days
},
});
export const { auth, signIn, signOut, store } = convexAuth({
providers: [
Password,
],
callbacks: {
async createOrUpdateUser(ctx, args) {
if (args.existingUserId) {
await ctx.db.patch(args.existingUserId, {
email: args.profile.email,
phone: args.profile.phone,
// Name goes here
});
return args.existingUserId;
} else {
return await ctx.db.insert('users', {
role: 'user',
email: args.profile.email,
// Name goes here
});
}
},
},
session: {
totalDurationMs: 1000 * 60 * 60 * 24 * 30, // 90 days
inactiveDurationMs: 1000 * 60 * 60 * 24 * 7, // 7 days
},
});
16 replies
CCConvex Community
Created by oscklm on 7/30/2024 in #support-community
Issue with asyncMap in convex-helpers and Next.js 14.2.5
I'm getting this issue when trying to build my next.js app within my monorepo. I'm using the convex-helpers in my backend package. I'm not sure what i can do, my target is set to ESNext for both next.js and my backend package.
yarn run v1.22.19
│ $ next build
│ ▲ Next.js 14.2.5
- Environments: .env.production

│ Creating an optimized production build ...
│ ✓ Compiled successfully
│ Linting and checking validity of types .Failed to compile.

│ ../../node_modules/convex-helpers/index.ts:15:22
│ Type error: Type 'Iterable<FromType>' can only be iterated through when using the '--downlevelIteration' flag
│ or with a '--target' of 'es2015' or higher.

13 | const promises: Promise<ToType>[] = [];
14 | let index = 0;
> 15 | for (const item of await list) {
| ^
16 | promises.push(asyncTransform(item, index));
17 | index += 1;
18 | }
│ error Command failed with exit code 1.
│ info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
│ command finished with error: command (/Users/oscklm/Code/work/flimmer-monorepo/apps/dashboard) /var/folders/rn
/rd71yf_115b60w3h6jfv16840000gn/T/yarn--1722335907430-0.34139340179029687/yarn run build exited (1)
└────>
@flimmer/dashboard#build: command (/Users/oscklm/Code/work/flimmer-monorepo/apps/dashboard) /var/folders/rn/rd71yf_115b60w3h6jfv16840000gn/T/yarn--1722335907430-0.34139340179029687/yarn run build exited (1)
yarn run v1.22.19
│ $ next build
│ ▲ Next.js 14.2.5
- Environments: .env.production

│ Creating an optimized production build ...
│ ✓ Compiled successfully
│ Linting and checking validity of types .Failed to compile.

│ ../../node_modules/convex-helpers/index.ts:15:22
│ Type error: Type 'Iterable<FromType>' can only be iterated through when using the '--downlevelIteration' flag
│ or with a '--target' of 'es2015' or higher.

13 | const promises: Promise<ToType>[] = [];
14 | let index = 0;
> 15 | for (const item of await list) {
| ^
16 | promises.push(asyncTransform(item, index));
17 | index += 1;
18 | }
│ error Command failed with exit code 1.
│ info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
│ command finished with error: command (/Users/oscklm/Code/work/flimmer-monorepo/apps/dashboard) /var/folders/rn
/rd71yf_115b60w3h6jfv16840000gn/T/yarn--1722335907430-0.34139340179029687/yarn run build exited (1)
└────>
@flimmer/dashboard#build: command (/Users/oscklm/Code/work/flimmer-monorepo/apps/dashboard) /var/folders/rn/rd71yf_115b60w3h6jfv16840000gn/T/yarn--1722335907430-0.34139340179029687/yarn run build exited (1)
20 replies
CCConvex Community
Created by oscklm on 7/19/2024 in #support-community
[ConvexAuth] getting jwtToken to pass to auth headers in fetch on client
Is there a way to get the jwtToken client side when authenticated, when using convex auth? i'd like to pass it in the auth headers of a fetch request from my client
fetch("https://<deployment name>.convex.site/uploadImage", {
headers: {
Authorization: `Bearer ${jwtToken}`,
},
});
fetch("https://<deployment name>.convex.site/uploadImage", {
headers: {
Authorization: `Bearer ${jwtToken}`,
},
});
Like for example with clerk you could do something like:
auth().getToken({ template: "convex" })
auth().getToken({ template: "convex" })
19 replies
CCConvex Community
Created by oscklm on 7/18/2024 in #support-community
[ConvexAuth] settings values of custom users fields, on user creation
Hey, i've been looking through the docs. And would imagine settings some values for the fields i have customized on the schema for users, when the users get created. Would be done in the account callback configuration? But looking at the API, i've failed to figure out how to use this callback: I wanna achieve setting some of the custom fields i define when i create a user
import { convexAuth } from '@convex-dev/auth/server';
import { Password } from '@convex-dev/auth/providers/Password';

export const { auth, signIn, signOut, store } = convexAuth({
providers: [Password],
callbacks: {
async createOrUpdateUser(ctx, args) {
// How do i know which account this is for?

// Create a new user
return await ctx.db.insert('users', {
accountId: accountIdFromSomewhere, // Account id from where ?
//..
// my custom fields
role: 'user',
});

// Handle different cases, like updating etc.
},
},
session: {
totalDurationMs: 1000 * 60 * 60 * 24 * 30, // 90 days
inactiveDurationMs: 1000 * 60 * 60 * 24 * 7, // 7 days
},
});
import { convexAuth } from '@convex-dev/auth/server';
import { Password } from '@convex-dev/auth/providers/Password';

export const { auth, signIn, signOut, store } = convexAuth({
providers: [Password],
callbacks: {
async createOrUpdateUser(ctx, args) {
// How do i know which account this is for?

// Create a new user
return await ctx.db.insert('users', {
accountId: accountIdFromSomewhere, // Account id from where ?
//..
// my custom fields
role: 'user',
});

// Handle different cases, like updating etc.
},
},
session: {
totalDurationMs: 1000 * 60 * 60 * 24 * 30, // 90 days
inactiveDurationMs: 1000 * 60 * 60 * 24 * 7, // 7 days
},
});
6 replies
CCConvex Community
Created by oscklm on 7/16/2024 in #support-community
Working with return validator and a query that enriches data
Hello, In our project, we use relational tables and in a query like the one below, where we wanna enrich video with its related data. We wanna use this new return validation, but find it a bit hard to get the returned object to actually match the validator we define. I'd love to ask for some advice on how to best approach this, as we are looking to do it quite a lot with other pieces of data in our app. Return validator:
export const videoEnrichedValidator = v.object({
_id: v.id('video'),
_creationTime: v.number(),
...videoValidator.fields,
enrichments: v.object({
activity: v.union(v.null(), activityValidator),
category: v.union(v.null(), categoryValidator),
thumbnails: v.union(
v.null(),
v.object({
small: v.union(v.string(), v.null()),
medium: v.union(v.string(), v.null()),
large: v.union(v.string(), v.null()),
})
),
muxAsset: muxAssetValidator,
}),
});
export const videoEnrichedValidator = v.object({
_id: v.id('video'),
_creationTime: v.number(),
...videoValidator.fields,
enrichments: v.object({
activity: v.union(v.null(), activityValidator),
category: v.union(v.null(), categoryValidator),
thumbnails: v.union(
v.null(),
v.object({
small: v.union(v.string(), v.null()),
medium: v.union(v.string(), v.null()),
large: v.union(v.string(), v.null()),
})
),
muxAsset: muxAssetValidator,
}),
});
10 replies
CCConvex Community
Created by oscklm on 7/13/2024 in #support-community
Return value validation question?
If i wanna use the return value validation in a function. And say that function returns an array of documents. How may i define the return value, as the doc. I have a myValidator exported from a validators.ts file that i can use like returns: v.array(videoValidator) But that ends up erroring, since what im returning is the result of a .collect() so basically what ends up coming through is system fields aswell. I don't see anything regarding validating returned objects containing system fields in the docs.
17 replies
CCConvex Community
Created by oscklm on 6/27/2024 in #support-community
Convex.json external packages not installing, pnpm monorepo
So there seems to be a lack of externalPackages to support a monorepo, like ours which uses node-linker=hoisted in a .npmrc The node-linker hoisted flattens and causes all modules to be installed in the root node_modules folder. So when we define externalPackages, in our convex.json like this:
{
"node": {
"externalPackages": ["sharp"]
}
}
{
"node": {
"externalPackages": ["sharp"]
}
}
The external packages doesn't get installed when running convex dev Comparing to a non monorepo project, this works without problems. A bit of a forced workaround, that solves the issue: Manually moving a "sharp" module from the root node_modules, into the packages/backend/node_modules, will solve this issue. But seems like a bit of a forceful workaround. Even though it does work.
5 replies
CCConvex Community
Created by oscklm on 6/24/2024 in #support-community
Issues when installing sharp in action with pnpm
Hey, trying to install sharp for my action. My monorepo is setup usng pnpm as packagemanager. Having trouble trying to install the correct prebuilt binary, so that it can run in the convex javascript runtime?
Error fetching POST https://hushed-koala-696.convex.cloud/api/push_config 400 Bad Request: InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
error:
Uncaught Failed to analyze image/actions.js: Could not load the "sharp" module using the linux-arm64 runtime
Possible solutions:
- Ensure optional dependencies can be installed:
npm install --include=optional sharp
yarn add sharp --ignore-engines
- Ensure your package manager supports multi-platform installation:
See https://sharp.pixelplumbing.com/install#cross-platform
- Add platform-specific dependencies:
npm install --os=linux --cpu=arm64 sharp
- Consult the installation documentation:
See https://sharp.pixelplumbing.com/install
at ../../node_modules/sharp/lib/sharp.js (../../../../node_modules/sharp/lib/sharp.js:114:0)
at __require2 (convex:/user/_deps/node/S732JE4B.js:19:50)
at ../../node_modules/sharp/lib/constructor.js (../../../../node_modules/sharp/lib/constructor.js:12:0)
at __require2 (convex:/user/_deps/node/S732JE4B.js:19:50)
at ../../node_modules/sharp/lib/index.js (../../../../node_modules/sharp/lib/index.js:6:0)
at __require2 (convex:/user/_deps/node/S732JE4B.js:19:50)
at <anonymous> (../../functions/image/actions.ts:2:18)
Error fetching POST https://hushed-koala-696.convex.cloud/api/push_config 400 Bad Request: InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
error:
Uncaught Failed to analyze image/actions.js: Could not load the "sharp" module using the linux-arm64 runtime
Possible solutions:
- Ensure optional dependencies can be installed:
npm install --include=optional sharp
yarn add sharp --ignore-engines
- Ensure your package manager supports multi-platform installation:
See https://sharp.pixelplumbing.com/install#cross-platform
- Add platform-specific dependencies:
npm install --os=linux --cpu=arm64 sharp
- Consult the installation documentation:
See https://sharp.pixelplumbing.com/install
at ../../node_modules/sharp/lib/sharp.js (../../../../node_modules/sharp/lib/sharp.js:114:0)
at __require2 (convex:/user/_deps/node/S732JE4B.js:19:50)
at ../../node_modules/sharp/lib/constructor.js (../../../../node_modules/sharp/lib/constructor.js:12:0)
at __require2 (convex:/user/_deps/node/S732JE4B.js:19:50)
at ../../node_modules/sharp/lib/index.js (../../../../node_modules/sharp/lib/index.js:6:0)
at __require2 (convex:/user/_deps/node/S732JE4B.js:19:50)
at <anonymous> (../../functions/image/actions.ts:2:18)
18 replies
CCConvex Community
Created by oscklm on 6/14/2024 in #support-community
Multiple actions in one file, using different node modules?
Hey, So i currently have a actions.ts holding my actions. In that i have multiple actions, and import some different modules at the top.
const client = new Mux({
tokenId: process.env.MUX_TOKEN_ID,
tokenSecret: process.env.MUX_TOKEN_SECRET,
});
const client = new Mux({
tokenId: process.env.MUX_TOKEN_ID,
tokenSecret: process.env.MUX_TOKEN_SECRET,
});
When i need to create a client like above, should i create these clients in the top of actions.ts or inside of the invidual actions? I would think that creating them inside the action, unless they are shared makes sense. Are there any docs or something that can better help outline the "life cycle" of an action and how it works when having multiple in one file. I'm very curious to better understand how this actually get "compiled" into runnable code?
3 replies