-
-
Couldn't load subscription status.
- Fork 388
[Icons] Do not fail application if there is not internet connection #3146
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: 2.x
Are you sure you want to change the base?
[Icons] Do not fail application if there is not internet connection #3146
Conversation
|
Hi Mateusz, by any chance were you at the Sylius Con in Lyon this last friday? :) About your changes, I already faced the same issue when working on a train/plane, where the connection was really bad and icons were not locked (ie #3084). |
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.
CI failures seem unrelated
EDIT: posted at zenstruck/foundry#1011 (comment)
| } catch (TransportException $e) { | ||
| $this->logger?->warning($e->getMessage()); | ||
|
|
||
| return ''; | ||
| } |
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.
We could merge this block with the catch (IconNotFoundException $e)
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.
The question is - should it be handled only if the ignoreNotFound flag is set to true, or it should work this way no matter what 🤔
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.
should it be handled only if the
ignoreNotFoundflag is set to true
IMO, yes
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.
Up to you, @Kocal 🖖 From my perspetive, a decision of not failing on not found icons is a consious choice: "if I define an unknown icon it should not fail" and in fact is an opt-in. On the other hand, not failing the application when something completely independent of the developer happens (like the internet connection problems) should be a default behaviour (or maybe opt-out 🤷).
Anyway, if you decide to cover this with the existing flag-based approach, I'm ok with that 🫡 but maybe in such a situation we should indeed just handle the TransportException in IconifyOnDemandRegistry and throw IconNotFoundException so no changes in the runtime service is needed. Again - up to you, I'm just a humble developer that found a bug 😄
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.
In my opinion I find it ridiculous that an app could returns a 500 if a single icon was not able to be downloaded on-the-fly (implying the icon was not imported/locked during development or deployment).
Your addition is nice (we still need to merge the 2 catch), however I think the DX could be improved.
I wasn't aware about this option, and I think some people too, but IMHO it would be nice to add a new Symfony Recipe for UX Icon with:
- the option set to
falsetrue, so we make it explicit - the option set to
truefalseinwhen@dev
Do you want to work on it? I can help you if you need.
Thanks!
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.
the option set to false, so we make it explicit
the option set to true in when@dev
IMO, ignoreNotFound should be true to prevent production to return a 500 when an icon is missing.
And false in when@dev
This is why that option was originally added: #2008
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.
Ah, yes indeed, I forgot what was the option name, but yes these errors should be silent in prod. I updated my message.
Indeed I was there 😅
Of course I had the bad luck opening the PR just after some dependencies updates break the build 😆 |
Hello 👋 First of all, thank you for amazing SymfonyUX initiative, it definitely brings a frash air in working with front-end for a total FE noobs like me 😅
I've recently encountered a rather unusual problem while playing in icons, still a pretty annoying one. I was coding in a plane and for some reason decided clear my cache. It resulted in a situation, when I had no icons information loaded in cache and they could not be fetched from the remote server as I had no internet connection✈️ It resulted in 500 error and not being able to use my application just because of the missing icons 😅 I believe such a situation should be handled by default and unablity to show icons should not break the application.
I propose the easiest possible solution - catching the
TransportExceptionon the high level in theUXIconRuntime. However, I suppose it could be done nicer, to not expose any registry specific information (in the end, only theIconifyOnDemandRegistrycould result in such error) - maybe we should handle it in the registry itself, and throw some more generic exception, likeIconsNotAvailableException? Or maybe even use the existingIconNotFoundException? 🤔 I didn't want to push any of these solutions, and would prefer to see the opinion of the library maintainers 🫡