-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
fix(provisioning): remove app from apps map when its provision failed #7070
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
base: master
Are you sure you want to change the base?
fix(provisioning): remove app from apps map when its provision failed #7070
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooo, thanks, that's an interesting case. Yeah it's probably best if the failed app is removed...
Hmm. I'm not sure this is a good enough solution. I think what might happen is if the app is referenced by more than one module (e.g. HTTP handler module gets a ref to the app), then it would try to provision the app many times (and probably fail every time), causing a lot of noise. Maybe the context should hold onto a map of failed apps (e.g. |
@francislavoie Interesting... (I've disabled auto-merge while we figure this out) Once a module fails to load, it should bubble the error up all the way, and cease trying to provision more modules, yeah? The config will proceed to unload and roll back to its previous state. |
I don't understand why Caddy continues to start then 🤔 With a bad config it should just throw it all away, no? Maybe I don't understand how Mercure is being used here. |
Nothing fancy here actually, Mercure app provision just starts by checking that provided keys are not empty, and it returns an error if they are |
@francislavoie Good question -- the stack trace shows that it's starting the I'm not strictly opposed to "noisy" logs though, but I do want to know why a failed module provisioning during config load allows the config to continue loading... I'll dig. |
Okay, I had some time to digest this. I don't fully understand it yet. Thanks @alexandre-daubois for proposing a fix. Even though I can't explain why, if the mercure module returns an error on This does feel like a band-aid (but also proper bookkeeping). As I don't have Docker to reproduce the issue, can anyone explain how it's possible that we're calling Lines 431 to 435 in 2f0fc62
after an error is returned here: Lines 401 to 405 in 2f0fc62
a few lines above? I pushed a commit to do the cleanup using defer, which is a little more robust and takes care of a failure from |
@alexandre-daubois -- or anyone else getting the error -- would you be able to confirm that the latest commit still "fixes" the issue? And if anyone knows why Start() proceeds to be called despite an error being returned, I'd love to be enlightened 😅 |
I just tested your fix and everything seems fine! Thank you Matt! |
Fix dunglas/symfony-docker#801
When starting FrankenPHP with Mercure and the default prod config, the publisher and subscriber keys are empty. This causes the Mercure app provision to fail, return an error in
Provision
and be partially started. It is then in an inconsistent state, and Caddy panics (as shown in the stacks trace of the original issue).By adding this new cleanup, we ensure the app isn't in the apps map anymore. Caddy doesn't panic anymore and the error message returned by Mercure is now successfully displayed in the console.
cc @dunglas