BLOCKER: Delivery engine crashes with nil pointer dereference on startup #17
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sneak/webhooker#17
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
The delivery engine crashes with a nil pointer dereference approximately 2 seconds after application startup.
Root Cause
In
internal/delivery/engine.go, theNew()constructor storesparams.DB.DB()at construction time:However,
Database.DB()returns the GORM*gorm.DBwhich is only set during the database'sOnStartlifecycle hook (inconnect()). The engine's constructor runs during fx dependency resolution, which happens before anyOnStarthooks fire. Thereforeparams.DB.DB()returnsnil.When the delivery engine's background goroutine first polls (after
pollInterval= 2 seconds), it callse.db.Where(...)on a nil pointer, causing the panic.Stack Trace
Fix
Store
params.DB(the*database.Databasewrapper) instead ofparams.DB.DB(), and call.DB()lazily inprocessPending()or in theOnStarthook:Alternatively, move the
dbassignment into the engine'sOnStarthook, which runs after the database'sOnStart.Reproduction
Impact
The application is unusable. It crashes on every startup before any webhook can be received or delivered. This blocks the 1.0 release.