-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Unexpected behaviour if caddyhttp.Route
is provisioned twice
#6551
Labels
bug 🐞
Something isn't working
Comments
Hmm, I guess that should be fine. Want to submit a PR? If it does break anything we'd appreciate your help to maintain patches :) |
jbro
added a commit
to jbro/caddy
that referenced
this issue
Sep 2, 2024
jbro
added a commit
to jbro/caddy
that referenced
this issue
Sep 2, 2024
jbro
added a commit
to jbro/caddy
that referenced
this issue
Sep 2, 2024
jbro
added a commit
to jbro/caddy
that referenced
this issue
Sep 2, 2024
Only glad to help :) I've created a PR here (Sorry for mixing accounts, I accidentally created the issue with my work account) |
mholt
pushed a commit
that referenced
this issue
Sep 3, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Let me just start with saying, that this is not something that was observed during normal Caddy operation. It's a corner case that arose because I'm using
caddyhttp.Route
from another Caddy module.The TL;DR of the issue is that because the
middleware
field incaddyhttp.Route
is appended to directly here, then if we ever callProvisionHandlers
more than once, the pre-compiled handlers will be added to themiddleware
field again, instead of reflecting the currentHandlers
.For a more convoluted example, and how I discovered it. What I do is, I have a Caddy module that embeds the
caddyhttp.Route
struct and I callProvision
on that embedding to trigger all the JSON magic that creates theRoute
object. A little later I look at theHandlers
field, and in some cases I add aRewrite.Rewrite
handler in front. Then I callProvisionHandlers
, followed byCompile
. Which I expected would have worked, but because of the pre-compile thing, theRewrite
handler is not at the top, and never hit because the lastHandler
is terminating.There is an easy fix though, which restores the expected behaviour without affecting Caddy's current behaviour:
I would be more than happy to raise a PR with that small change. I just want to make sure that I haven't misunderstood what is going on.
The text was updated successfully, but these errors were encountered: