Skip to content

Reset default EntrypointLookup on exception to fix #21 and #73 #74

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

Merged
merged 1 commit into from
Jan 31, 2020
Merged

Reset default EntrypointLookup on exception to fix #21 and #73 #74

merged 1 commit into from
Jan 31, 2020

Conversation

tbmatuka
Copy link
Contributor

@tbmatuka tbmatuka commented Aug 6, 2019

Since @ckrack seems to be unavailable to continue working on #21, I figured this would be faster :)

I don't like having _default hardcoded in the listener, but I see no other options right now.
I thought about adding a resetAll() method to EntrypointLookupCollection, but there were a couple of issues with that:

  1. It would either be a BC break if I added it to the interface, or an important method that isn't interfaced and I don't really like either of those.
  2. I couldn't even implement it because the container that we get in the collection only has has() and get() methods, so I couldn't go through it. This would also have to be replaced (and break BC) to implement resetAll().

Fixes symfony/demo#910

@Lyrkan
Copy link
Contributor

Lyrkan commented Aug 8, 2019

I don't like having _default hardcoded in the listener, but I see no other options right now.
I thought about adding a resetAll() method to EntrypointLookupCollection, but there were a couple of issues with that

Wouldn't it be possible to handle that using the WebpackEncoreExtension (even though I agree that having a all() and/or a resetAll() in the EntrypointLookupCollection would have been a better solution)?

  1. add a $builds argument to the constructor of webpack_encore.exception_listener
  2. use $container->getDefinition('webpack_encore.exception_listener')->replaceArgument(...) to inject the list of available builds in it

@tbmatuka
Copy link
Contributor Author

tbmatuka commented Aug 8, 2019

I made it work like you suggested. I still don't love it, but I like it a lot better than before.

Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

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

Minor comments - thanks for moving this forward!

{
private $entrypointLookupCollection;

private $entrypointNames;
Copy link
Member

Choose a reason for hiding this comment

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

I believe these are buildNames - we should change entrypoint -> build everywhere in this class

@@ -0,0 +1,26 @@
<?php

namespace Symfony\WebpackEncoreBundle\EventListener;
Copy link
Member

Choose a reason for hiding this comment

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

can you add LICENSE header at the top?

$this->entrypointLookupCollection->getEntrypointLookup($entrypointName)->reset();
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Could we add a very basic unit test for this class? There isn't much to test, but having at least ONE basic test will protect us from making any super silly typos now or in the future.

<service id="webpack_encore.exception_listener" class="Symfony\WebpackEncoreBundle\EventListener\ExceptionListener">
<tag name="kernel.event_listener" event="kernel.exception" />
<argument type="service" id="webpack_encore.entrypoint_lookup_collection" />
<argument /> <!-- build list of entrypoint paths -->
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<argument /> <!-- build list of entrypoint paths -->
<argument /> <!--collection of build names -->

@tbmatuka
Copy link
Contributor Author

tbmatuka commented Aug 9, 2019

@weaverryan should be all done, can you take a look?

@tbmatuka tbmatuka requested a review from weaverryan September 12, 2019 09:41
@tbmatuka
Copy link
Contributor Author

tbmatuka commented Nov 5, 2019

@weaverryan @Lyrkan this has been waiting for review/merge almost three months now, can we please move it along?

@weaverryan
Copy link
Member

Sorry for the long delay @tbmatuka - but thank you SO much for finishing this :). Cheers!

@weaverryan weaverryan merged commit da36629 into symfony:master Jan 31, 2020
emodric added a commit to netgen/media-site that referenced this pull request Jan 31, 2020
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.

Tricky error related to 500 error pages
3 participants