laravel/framework

New Version of Chrome cannot render dd function in network preview window

friparia opened this issue · 33 comments

  • Laravel Version: 5.4.* and 5.5.*
  • PHP Version: 7.0.13
  • Database Driver & Version: Mysql 5.6

Description:

When updated to chrome version 62.0.3202.66, dd function cannot be rendered by chrome network preview window.

fzr n2qqt 1c4hpj wu6a

And I have found the changelog of chrome. Commit f674b40baf2d44d1b27f33b3ed39e60b2b9169da says it will not render as HTML agressively if requested via XHR.

Steps To Reproduce:

  1. Update to chrome version 62.0.3202.66
  2. Execute a dd function
  3. Check the chrome network preview window

it is releated to issue #21317 . I think the reason is new version of chrome consider the javascript is agressive, so it will not render.

I read the chrome source code, it will use base64 to encode the response body first, and then render the html, so it may cause javascript not be rendered?

This is symfony/var-dumper issue.

ok, i will transfer this issue to symfony

I think this is Chrome issue, have you find any solution for this issue?
The dd() or var_dump() only present html but with the 500 error, chrome still render correctly.
I see the different is the html tag, the 500 error has the<html></html>but the dd() missed these tag.

How to fix this???

@tonghia I tested after adding <html></html> tag, it also doesn't work.
@alinasiri1367 there are some approaches to solve it in this issue

Using die($item) instead of dd($item) on a model renders the json in the network tab same as a json response. The object have to implement __toString() though.

Here is my solution. i don't know its the right way or not , but its working for now. if anyone have any better solution please share with us..
print "<pre>"; print_r(Excel::load($content['excel_file'])->all()->first()->keys()->toArray()); print "</pre>"; exit();
Results :

Array
(
    [0] => id_subscription
    [1] => language
    [2] => purl_en_yes
    [3] => purl_en_no
    [4] => purl_fr_yes
    [5] => purl_fr_no
    [6] => fullname
    [7] => email
    [8] => groupusr
    [9] => html
    [10] => fname
    [11] => lname
)

This function works pretty well for me. Only handles the HTML Dumper, not the CLI dumper, so it wont work in artisan commands, but if you're using those you can just use the normal dd() function.

function _dd(...$args)
{
    $content = "<!DOCTYPE html><html><body>";

    foreach ($args as $arg) {
        $val = (new \Symfony\Component\VarDumper\Cloner\VarCloner)->cloneVar($arg);
        $dumper = new \Illuminate\Support\Debug\HtmlDumper;
        $content .= $dumper->dump($val, true);
    }

    $content .= "</body></html>";

    return response($content, 500)->header('Content-Type', 'text/html')->send();
}

chrome has fixed this bug...

Im using chrome version 67.0.3396.99 and i still have the issue, @friparia in which version has been fixed?

@quarkmarino in chrome 67 i had to use this custom function somewhere in the helpers directory.

if (!function_exists('_dd')) {
 function _dd($args)  
    {  
        http_response_code(500);  
        dd($args);  
    }  
}

then use this function _dd($your-collection) to dump

I had the same problem on my mac. I had a Chrome version 67.xxx
and after updating to 68.0.3440.75 I can scroll again.

Yeah, I've updated to 68 and it works again, "Sweet sweet preview scroll, never leave me again"

If you want to change status to 500 for your ajax requests you just need to update

project/vendor/symfony/var-dumper/Dumper/HtmlDumper.php
class on line 111 where dump() method exists.
Just add line http_response_code(500); at the beginning of function. It works for Laravel 5.6 version.

a bit out of topic but maybe save someone's time
mine was cannot displaying 500 error in chrome

for me it is because Access-Control-Allow-Origin not granted to the server ,
200 can go through but 500 error not showing
.. no preflight error or what, 2 hours wasted

in chrome 69 it don't work :(

  • Laravel Version: 5.4.* and 5.5.*
  • PHP Version: 7.0.13
  • Database Driver & Version: Mysql 5.6

Description:

When updated to chrome version 62.0.3202.66, dd function cannot be rendered by chrome network preview window.

fzr n2qqt 1c4hpj wu6a

And I have found the changelog of chrome. Commit f674b40baf2d44d1b27f33b3ed39e60b2b9169da says it will not render as HTML agressively if requested via XHR.

Steps To Reproduce:

  1. Update to chrome version 62.0.3202.66
  2. Execute a dd function
  3. Check the chrome network preview window

Put header('Content-Type: text/html'); before of the dd or dump.

Same here... any thoughts?

@tnatanael new version should work tho.

Version 72.0.3626.81 (Official Build) (64-bit)

Laravel 5.4

Not working...

Laravel 5.4 is not even supported and out of support :)

:'-( crying a lot...

There was an update to Chrome recently (72) that broke this again. Laravel 5.4 being unsupported is irrelevant here.

There was an update to Chrome recently (72) that broke this again. Laravel 5.4 being unsupported is irrelevant here.

Put header('Content-Type: text/html'); before of the dd or dump.

header('Content-Type: text/html');

Also does not work! Thanks for the try!

This bug is back on Chrome 72. Also for laravel 5.5. The easiets solution (for me and for now), is downgrade google-crome-stable to version 71.

You can download here: https://www.slimjet.com/chrome/google-chrome-old-version.php

This seems to be a bug in Chrome 72, indeed.

Same problem :( with Version 72.0.3626.109 (Official Build) (64-bit)

As this is just becoming a dumping ground for people reporting that they have the issue I'm locking this. We can't do anything to fix this ourselves.