Skip to content

fix: cache Webhook dynamic import to avoid repeated import() calls#1045

Merged
ferhatelmas merged 1 commit into
supabase:masterfrom
mcollina:cache-webhook-dynamic-import
Apr 23, 2026
Merged

fix: cache Webhook dynamic import to avoid repeated import() calls#1045
ferhatelmas merged 1 commit into
supabase:masterfrom
mcollina:cache-webhook-dynamic-import

Conversation

@mcollina
Copy link
Copy Markdown
Contributor

Remove dynamic import of Webhook as it was showing up in flamegraphs.

Copilot AI review requested due to automatic review settings April 23, 2026 13:34
@mcollina mcollina requested a review from a team as a code owner April 23, 2026 13:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes repeated import() overhead in storage event webhook dispatching by caching the dynamically imported Webhook class in BaseEvent, reducing runtime cost that was visible in flamegraphs.

Changes:

  • Add a module-scoped cache for the Webhook export from ./lifecycle/webhook.
  • Update BaseEvent.sendWebhook() to import Webhook only once and reuse it for subsequent calls.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 24838264429

Coverage increased (+0.002%) to 69.946%

Details

  • Coverage increased (+0.002%) from the base build.
  • Patch coverage: 3 of 3 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 9692
Covered Lines: 7149
Line Coverage: 73.76%
Relevant Branches: 5414
Covered Branches: 3417
Branch Coverage: 63.11%
Branches in Coverage %: Yes
Coverage Strength: 375.25 hits per line

💛 - Coveralls

@ferhatelmas ferhatelmas merged commit 6474bf5 into supabase:master Apr 23, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants