Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database Webhooks get fired >1s after record inserted #175

Open
2 tasks done
davidfant opened this issue Jun 30, 2024 · 4 comments
Open
2 tasks done

Database Webhooks get fired >1s after record inserted #175

davidfant opened this issue Jun 30, 2024 · 4 comments

Comments

@davidfant
Copy link

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When a record is inserted I have a database webhook trigger that points at a Supabase function. There is always a delay of slightly over 1s between when a record is inserted (record.created_at) and when the trigger is fired. I'm running this locally, so there should be minimal networking overhead

For example:

Record created at: 2024-06-30T10:20:40.036685+00:00
new Date() in supabase function: 2024-06-30T10:20:41.129Z

To Reproduce

  1. Create a table
  2. Set up a database webhook trigger pointing at a Supabase function. console.log both record.created_at and new Date() to see the times
  3. Insert a record into the table

Expected behavior

Webhooks should be fired ~immediately

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: macOS
  • Browser (if applies) -
  • Version of supabase-js: 2.43.4
  • Version of Node.js: v21.1

Additional context

If it's not related to an actual issue in Supabase, please let me know anything I can do to cut down on the latency

@davidfant davidfant added the bug Something isn't working label Jun 30, 2024
@encima
Copy link
Member

encima commented Jul 1, 2024

Hi there,
thanks for opening. You might need to give some more information here if that is OK.

The firing happens 1 second after you make a call to insert? Or it is 1 second after the insert has happened?

Is the insert a single record, or multiple? Are there any indexes or other constraints on the table?

Does the time decrease once the function has been called a few times (i.e. is it the startup time of the functions causing this or is it the delay from the trigger)

@davidfant
Copy link
Author

@encima

  1. 1s from whenever the time the database NOW() is run to set the default created_at column value. All DB calls are pretty much instant because I'm running it locally and have an empty database, so that's certainly not taking 1s.
  2. Single record
  3. No indexes but 1 FK
  4. The time is always slightly above 1s, even when I run it 100 times

@davidfant
Copy link
Author

@encima @Hallidayo let me know if I can provide any additional details!

@Hallidayo
Copy link

@davidfant - I'll try this out and come back to you.

@steve-chavez steve-chavez transferred this issue from supabase/supabase Jan 23, 2025
@steve-chavez steve-chavez removed the bug Something isn't working label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

4 participants