I'm struggling to identify the cause of 404's when using the Symfony2 profiler. I'm using Symfony 2.3 LTS.
I have the profiler enabled on our development environments and the issue is reproducible across several developer machines. Our configuration for the profiler is:
framework:
profiler:
dsn: "memcached://localhost:11211"
enabled: true
lifetime: 86400 # Keep profiles for a day at most
On some - but not all - pages we are seeing an error as follows:
**The page at https://local.dev says:**
An error occurred while loading the web debug toolbar (404: Not Found).
Do you want to open the profiler?
OK / Cancel
There are 5 404 requests for https://local.dev/_wdt/<token>
and clicking Cancel takes us to a "Token not found" page at https://local.dev/_profiler/<token>
I've tried stepping through the code and so far have determined:
- If I place a breakpoint in the
ProfilerListener
atonKernelResponse
I can identify the unique parent token. - After
$this->saveProfiles($profile);
, I can manually query memcached using telnet for the token and receive the expected serialised array. - If I step through the code, I eventually find myself in
TraceableEventDispatcher
. InsaveInfoInProfile
there is a loop over the children items of the profile which calls$this->saveInfoInProfile($child, true);
. There are 6 children items in my case here, and the first 5 are persisted as expected. - After 5 iterations of
saveInfoInProfile
the original token can be retrieved via telnet and still appears. - On the 6th (last) iteration, a call is made in
MemcachedProfilerStorage
to$this->getMemcached()->set($key, $value, time() + $expiration);
. - Before this call is made, I can still retrieve the original token via telnet.
However, after this call is made, the telnet request for the original token returns empty. The key for this call is distinct from the original token, so it is not being overwritten.
This in turn triggers the 404 error I'm seeing client side.
Some additional potentially useful information:
- The toolbar does work on some pages. It's pages within our admin interface that are having 404 toolbar errors.
- We're using ESI and using Twig.
- We're making calls to
{% render(controller("ABundle:AController:anAction", {some:params})) %}
- Eliminating one of the render methods from one of our Twig templates resolves the issue.
- Reinstating that render method and commenting out a different one will also resolve the issue. Implying there are too many children or too much data (or something similar).
What could be causing this issue? How would I identify a fix?
As an aside, using the FileProfiler works correctly.
Thank you for any assistance!