gwuhaolin / chrome-render

general server render base on headless chrome
95 stars 10 forks source link

cookies setting (it appears) causes chrome-remote-interface to crash #7

Closed gajus closed 7 years ago

gajus commented 7 years ago

Code:

chromeRenderer.render({
  cookies: {
    // This cookie is used by the @applaudience/go2cinema-web-app to identify
    // the prerender.
    // eslint-disable-next-line id-match
    GO2CINEMA_RENDERER: 1
  },
  deviceMetricsOverride,
  url,
  useReady: true
});

Here is the log:

{ method: 'Page.enable', params: undefined }
{ method: 'DOM.enable', params: undefined }
{ method: 'Network.enable', params: undefined }
{ method: 'Console.enable', params: undefined }
{ method: 'Network.setCookie',
  params:
   { url: 'https://go2cinema.com',
     name: 'GO2CINEMA_RENDERER',
     value: 1 } }
{ method: 'Page.addScriptToEvaluateOnLoad',
  params: { scriptSource: '\nObject.defineProperty(window, \'isPageReady\', {\n  set: function() { console.log(\'P_R\'); },\n})' } }
{ method: 'Network.setExtraHTTPHeaders',
  params: { headers: { 'x-chrome-render': '1.2.0' } } }
{ method: 'Emulation.setDeviceMetricsOverride',
  params:
   { deviceScaleFactor: 1,
     fitWindow: false,
     height: 1080,
     mobile: false,
     width: 1920 } }
{ method: 'Page.navigate',
  params: { url: 'https://go2cinema.com', referrer: undefined } }
error true

Not sure whats the issue yet.

gajus commented 7 years ago

It looks like the issue is because cookies member value must be a string.