Database Webhooks get fired >1s after record inserted
Bug report
- [X] I confirm this is a bug with Supabase, not with my own application.
- [X] 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
- Create a table
- Set up a database webhook trigger pointing at a Supabase function.
console.logboth record.created_at andnew Date()to see the times - 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
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)
@encima
- 1s from whenever the time the database
NOW()is run to set the defaultcreated_atcolumn 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. - Single record
- No indexes but 1 FK
- The time is always slightly above 1s, even when I run it 100 times
@encima @Hallidayo let me know if I can provide any additional details!
@davidfant - I'll try this out and come back to you.