Skip to content

Debugger.sendCommand callback passes an empty error object on success #14811

Closed

Description

@bughit
  • Output of node_modules/.bin/electron --version: 3.0.0 x86
  • Operating System (Platform and Version): win7 sp1 x64

Expected Behavior
to make it easy to differentiate success from failure, error should be null/undefined on success

Actual behavior
error is an empty object

[2018-09-26T02:17:14.805Z] sendCommand callback:
error: {}
result: {}

To Reproduce
run the following

'use strict';

const {app, BrowserWindow} = require('electron'),
      OFFSCREEN = true;

let win;

if (OFFSCREEN)
  app.disableHardwareAcceleration();

app.on('ready', () => {

  win = new BrowserWindow({
    width: 1440,
    height: 900,
    useContentSize: true,
    show: !OFFSCREEN,
    webPreferences: {
      nodeIntegration: false,
      partition: 'memory_partition_1',
      offscreen: OFFSCREEN
    },
  });

  if (OFFSCREEN) {
    win.webContents.setFrameRate(1);
    win.webContents.stopPainting();
  }

  win.webContents.on('did-stop-loading', event => {
    log('did-stop-loading: %s', win.webContents.getURL());
    setTimeout(exit, 2000);
  });


  const dev = win.webContents.debugger;
  dev.attach();
  dev.on('message', (event, method, params) => {
    log('%s:\n%O', method, params);
  });

  log('before sendCommand');
  dev.sendCommand('Page.enable', {}, (error, result) => log('sendCommand callback:\nerror: %O\nresult: %O', error, result));
  log('after sendCommand');

  setTimeout(() => {
    log('before loadURL');
    win.loadURL('http://example.org/');
    log('after loadURL');
  });

});

function log(msg, ...args) {
  console.log(`[${new Date().toISOString()}] ${msg}\n`, ...args);
}

function exit() {
  log('exiting');
  app.exit();
}

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions