SupabaseS
Supabaseβ€’5w ago
welydev

Edge Function 500 error : Different behavior in different supabase projects

Hello there πŸ‘‹ ,
I'm having trouble understanding my current issue and I'm running out of possible solution...

Issue : When I invoke my search-word edge function, I get a 500 error in the invocation logs.

Details
  • I have two projects in supabase : prod and dev
  • In both projects I have the same edge functions : search-word & prepare-training-data with similar setup : NO Verify JWT with legacy secret
  • prepare-training-data works well in both projects (invoked and logs are ok)
  • search-word works well in dev project (invoked and logs are ok)
  • search-word is never invoked in prod project and I get a 500 http error in the invocation logs
This is how I invoke both :
// in searchWord.ts
export async function searchWord(word: string): Promise<WordSearchResult | WordSearchError> {
  try {
    const { data: { session } } = await supabase.auth.getSession();
    if (!session) {
      return {
        error: 'User not authenticated',
        errorKey: 'auth.errors.notAuthenticated'
      };
    }
    const { data, error: errorData } = await supabase.functions.invoke('search-word', {
      body: JSON.stringify({ word: word.trim() }),
    });
    ...
}

// in trainingData.ts 
  try {
    const { data: { session } } = await supabase.auth.getSession();
    if (!session) {
      return {
        error: 'User not authenticated',
        errorKey: 'auth.errors.notAuthenticated'
      };
    }
    const { data, error } = await supabase.functions.invoke('prepare-training-data');
    if (error) {
      console.error('Error calling prepare-training-data function:', error);
      return {
        error: 'Failed to fetch training data',
        errorKey: 'training.errors.fetchFailed',
        message: error.message
      };
    }
    ...
}
Was this page helpful?