Skip to content
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

DeprecationWarning with Electron 8.0.0 #180

Closed
jruuska opened this issue Feb 4, 2020 · 6 comments
Closed

DeprecationWarning with Electron 8.0.0 #180

jruuska opened this issue Feb 4, 2020 · 6 comments

Comments

@jruuska
Copy link

jruuska commented Feb 4, 2020

Hi,

a deprecation warning is being shown when electron-log is used with Electron 8.0.0 and
webPreferences: { nodeIntegration: true } is set.

(node:69267) DeprecationWarning: Passing functions, DOM objects and other non-cloneable JavaScript objects to IPC methods is deprecated and will throw an exception beginning with Electron 9.

The problem seems to be these 2 lines
https://github.com/megahertz/electron-log/blob/master/src/transports/ipc.js#L28
https://github.com/megahertz/electron-log/blob/master/src/electronApi.js#L123
related to this change electron/electron#20214

Steps to reproduce

node@12.14.1
electron@8.0.0
electron-log@4.0.5
$ npx electron ./tests/test.js
08:40:02.497 › App ready!
(node:69513) DeprecationWarning: Passing functions, DOM objects and other non-cloneable JavaScript objects to IPC methods is deprecated and will throw an exception beginning with Electron 9.
(node:69513) DeprecationWarning: Passing functions, DOM objects and other non-cloneable JavaScript objects to IPC methods is deprecated and will throw an exception beginning with Electron 9.

test.js

const path = require('path')
const electron = require('electron')
const { app, BrowserWindow } = electron
const logger = require('electron-log')

app.allowRendererProcessReuse = true

app.once('ready', () => {
  logger.info('App ready!')

  const win = new BrowserWindow({
    webPreferences: {
      nodeIntegration: true
    }
  })

  win.loadURL(`file://${path.resolve(__dirname, 'index.html')}`)
})

index.html

<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <title>Test</title>
</head>
<body>
  <h1>Hello</h1>
</body>
@megahertz
Copy link
Owner

Thank you for the detailed report, I'll investigate it a bit later.

@BVSPHari
Copy link

BVSPHari commented Mar 4, 2020

DeprecationWarning: Passing functions, DOM objects and other non-cloneable JavaScript objects to IPC methods is deprecated and will throw an exception beginning with Electron 9.

getting same error when used local html file path to loadURL method.

@megahertz
Copy link
Owner

@BVSPHari Could you provide a code example which produces such a warning?

@raphinesse
Copy link

This still happens with electron-log@4.1.0 when using scopes:

test.js

const { app, BrowserWindow } = require('electron');
const log = require('electron-log').scope('main');

let win;
app.once('ready', () => {
    win = new BrowserWindow({
        webPreferences: {
            nodeIntegration: true,
        },
    });

    log.info('Created window!');

    win.loadURL(`file:///${__dirname}/index.html`);
});

index.html

<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <title>Test</title>
</head>
<body>
  <h1>Hello</h1>
  <script>
    require('electron-log').scope('renderer').info('Hello!');
  </script>
</body>

@megahertz
Copy link
Owner

Thank you for the example @raphinesse, I'll try to fix that on this week.

@megahertz megahertz reopened this Mar 25, 2020
@raphinesse
Copy link

Thanks for your quick fix. Works great for me! 🏅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants