supabase-community / chatgpt-your-files

Production-ready MVP for securely chatting with your documents using pgvector
https://youtu.be/ibzlEQmgPPY
365 stars 126 forks source link

fix: increase pg_net http timeout #15

Closed gregnr closed 10 months ago

gregnr commented 10 months ago

Problem

We were consistently seeing this error in the embed edge function:

client connection error (hyper::Error(IncompleteMessage))

Which was caused by the pg_net HTTP client closing the connecting too early due to a timeout (2000 ms).

Solution

Generating embeddings can take time, so this PR increases the timeout to 300000 ms (5 minutes) by default, and also allows you to specify a custom timeout via an optional fourth trigger argument:

create trigger embed_document_sections
  after insert on document_sections
  referencing new table as inserted
  for each statement
  execute procedure private.embed(content, embedding, 5, 300000);

Fixes https://github.com/supabase-community/chatgpt-your-files/issues/11.