Skip to content

feat: match edge functions by header #7439

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

Conversation

eduardoboucas
Copy link
Member

Summary

Adds support for matching edge functions by header.

@eduardoboucas eduardoboucas requested a review from a team as a code owner July 18, 2025 12:35
Copy link

github-actions bot commented Jul 18, 2025

📊 Benchmark results

Comparing with 69134d2

  • Dependency count: 1,082 (no change)
  • Package size: 288 MB (no change)
  • Number of ts-expect-error directives: 399 (no change)

Copy link
Member

@serhalp serhalp left a comment

Choose a reason for hiding this comment

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

LGTM. just a couple suggestions.

@@ -421,6 +421,34 @@ export class EdgeFunctionsRegistry {
return
}

if (route.headers && headers) {
Copy link
Member

Choose a reason for hiding this comment

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

🤔 what happens if route.headers but !headers? we might intend to match specific headers but we wouldn't run that logic? is !headers every expected? could we handle this more gracefully and explicitly?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we should ever hit !headers, though. Removed in 3cc29d0.

return pattern.test(headerValueString)
}

return false
Copy link
Member

Choose a reason for hiding this comment

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

am I reading correctly that this is an invalid user configuration? since we're in dev, it might be helpful DX to print a user warning in this case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really. This is an internal structure that has been generated from parsing the edge function files and the TOML config. If there's an error in syntax, it will be thrown by edge-bundler.

From my tests, we might need some additional logic to surface those errors better (unrelated to this PR), which I'll do in a follow-up.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I've done it in 7d6f789 because it's a small fix (and you now you're obliged to review!).

@eduardoboucas eduardoboucas merged commit 21e4bc5 into main Jul 18, 2025
67 of 68 checks passed
@eduardoboucas eduardoboucas deleted the eduardo/run-1782-add-edge-function-matching-by-header-to-cli branch July 18, 2025 15:20
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.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy