Skip to content
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

Forward requests - Missing Assets after first forward. #94

Closed
Warxcell opened this issue Jul 15, 2020 · 3 comments
Closed

Forward requests - Missing Assets after first forward. #94

Warxcell opened this issue Jul 15, 2020 · 3 comments

Comments

@Warxcell
Copy link
Contributor

Warxcell commented Jul 15, 2020

I found that https://github.com/symfony/webpack-encore-bundle/blob/master/src/Asset/EntrypointLookup.php#L84-L87
causes 1+N request to don't have assets.

This is my use case:

I have several private page that I need to export as PDF.
Because they are private (needs authentication) - I make several forward request to get generated HTML.
And then pass the generated HTML to service that generates PDF from HTML.

But all pages after first one have broken styles.

@hktr92
Copy link

hktr92 commented Sep 7, 2020

same issue happens if you try to render an HTML response in kernel.exception. after a few minutes of debugging I've came to the same conclusion as you.

as for a solution, I might come up with one after some further experiments.

I had to inject EntrypointLookupInterface service in my responder and call reset() method in order to return the $newFiles array. I've seen in #90 to discuss already about this one.

@Warxcell
Copy link
Contributor Author

Warxcell commented Sep 8, 2020

currently I have this, which resolves the issue:

<?php

declare(strict_types=1);

namespace App\EventListener;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupInterface;

class ResetAssets implements EventSubscriberInterface
{
    private EntrypointLookupInterface $entryLookup;

    public function __construct(EntrypointLookupInterface $entryLookup)
    {
        $this->entryLookup = $entryLookup;
    }

    public static function getSubscribedEvents()
    {
        return [
            KernelEvents::RESPONSE => 'resetAssets',
        ];
    }

    public function resetAssets(ResponseEvent $event)
    {
        $this->entryLookup->reset();
    }
}

But it's better to be fixed in vendor.

Warxcell added a commit to Warxcell/webpack-encore-bundle that referenced this issue Mar 19, 2021
Warxcell added a commit to Warxcell/webpack-encore-bundle that referenced this issue Mar 19, 2021
weaverryan pushed a commit to Warxcell/webpack-encore-bundle that referenced this issue Feb 10, 2022
weaverryan added a commit that referenced this issue Feb 10, 2022
This PR was merged into the main branch.

Discussion
----------

Reset assets on FINISH_REQUEST.

Fixes #90, #94

Commits
-------

029b01b Reset caches on FINISH_REQUEST. Fixes #90, #94
@maxhelias
Copy link

Should be fixed no ?

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

No branches or pull requests

4 participants