Skip to content

deduplicate registration-time duplicates from match directives,#2487

Open
henderkes wants to merge 1 commit into
mainfrom
fix/worker-duplication
Open

deduplicate registration-time duplicates from match directives,#2487
henderkes wants to merge 1 commit into
mainfrom
fix/worker-duplication

Conversation

@henderkes

Copy link
Copy Markdown
Contributor

fixes #2477

it's a really bad workaround, but I can't think of a better way without a major rework for the match matching logic

@henderkes henderkes requested a review from AlliBalliBaba June 24, 2026 04:09
@henderkes henderkes force-pushed the fix/worker-duplication branch from 462a8ba to 8dabdb4 Compare June 24, 2026 05:56
@AlliBalliBaba

Copy link
Copy Markdown
Contributor

I think the issue comes from Provision() being called twice, seems like caddy detects 2 modules (only happens with php_server, not php.

@AlliBalliBaba

AlliBalliBaba commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Talking about these 2 lines, it creates an extra module instead of using the same one (= provision twice)

HandlersRaw: []json.RawMessage{caddyconfig.JSONModuleObject(phpsrv, "handler", "php", nil)},

caddyconfig.JSONModuleObject(f, "handler", "php", nil),

I think there's a way to do named routes and invoke the same module twice instead of having separate modules, not sure how messy that is in comparison.

@AlliBalliBaba

Copy link
Copy Markdown
Contributor

Thinking about it again, cleanest option is probably a separate handler directive.

Something like this:

// in caddy.go:Init()
httpcaddyfile.RegisterHandlerDirective("php_without_provision", parseCaddyfileWithoutProvision)`
// in module.go
func parseCaddyfileWithoutProvision(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) {
	m := &FrankenPHPModule{ skipProvision:true }
	err := m.UnmarshalCaddyfile(h.Dispenser)

	return m, err
}

func (f *FrankenPHPModule) Provision(ctx caddy.Context) error {
	if f.skipProvision {
		return nil // this module should skip the provision step
	}
	// ...
}

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.

Worker mode not working as expected

2 participants