-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Tricky error related to 500 error pages #910
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
Tricky error related to 500 error pages #910
Comments
for some reason that I don't not understand either, the generated link tag is empty, event if the asset is found. Adding, a dump, and a var_dump shows the difference, see the screenshot below and the associated code Corresponding debug code
I don't understand yet, why If someone has already experienced something similar in the past... |
The reason is, that webpack-encore-bundle's |
// webpack-encore-bundle/src/Asset/EntrypointLookup.php
public function getCssFiles(string $entryName): array
{
+ dump('returned files:', $this->returnedFiles);
return $this->getEntryFiles($entryName, 'css');
}
// ...
private function getEntryFiles(string $entryName, string $key): array
{
$this->validateEntryName($entryName);
$entriesData = $this->getEntriesData();
$entryData = $entriesData['entrypoints'][$entryName];
if (!isset($entryData[$key])) {
// If we don't find the file type then just send back nothing.
return [];
}
// make sure to not return the same file multiple times
$entryFiles = $entryData[$key];
+ dump('entryfiles:', $entryFiles);
+ dump('diff entry and existing returned', array_diff($entryFiles, $this->returnedFiles));
$newFiles = array_values(array_diff($entryFiles, $this->returnedFiles));
$this->returnedFiles = array_merge($this->returnedFiles, $newFiles);
+ dump('wrote returned files');
+ dump('newfiles', $newFiles);
return $newFiles;
} Output from calling
Output from calling:
The difference is the empty vs non-empty array in the first dump. |
On /en/blog/posts/lorem-ipsum-dolor-sit-amet-consectetur-adipiscing-elit, we get an immediate exception (TableNotFoundException) due to ParamConverter, so EntrypointLookup is fresh and we get the wanted css. On /en/blog, index is load without error, so EntryLookup fill $returnedFiles as expected; then error is thrown when really loading $post (in for loop in twig). So another request is 'launched' to handle the TwigError but we stay in the same context, with the returnedFiles previously load. Not sure how to fix that though. |
Maybe webpack-encore can add an exception listener to call the reset method ? |
Ah, so the problem is that Symfony loads page with the CSS, but then a sub-request is started for the Exception which doesn't have the CSS as this was part of the main page. Good catch folks 👍 |
You guys nailed it. I’m also not sure what the best fix is. We could reset in an e caption listener... but more abstractly, if you make a sub-request that returns a full HTML page (yes, that’s uncommon outside of error pages but possible), shouldn’t the entry files cache used for that sub-request be different than the entry files cache used on the master request? |
This is what i had in mind in my fix. |
…(tbmatuka) This PR was squashed before being merged into the master branch (closes #74). Discussion ---------- Reset default EntrypointLookup on exception to fix #21 and #73 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 Commits ------- da36629 Reset default EntrypointLookup on exception to fix #21 and #73
Let's close this old and edge-case issue. I haven't faced it since I reported it or I wasn't aware of facing the issue, so it's not important anymore. Thanks. |
Yesterday I merged #909 as an (ugly) temporary solution to a very tricky error.
How to reproduce the error:
prod
anddebug=0
in.env
DATABASE_URL
config to trigger a 500 error/en/blog/posts/lorem-ipsum-dolor-sit-amet-consectetur-adipiscing-elit
/en/blog/
Can anyone spot the reason and provide a pull request to fix it? Thanks!
The text was updated successfully, but these errors were encountered: