Skip to content

zone-mix: Cannot read property 'eventNames' of undefined #31626

@rezonant

Description

@rezonant

After upgrading from Angular 7 to Angular 8, our Electron builds break seemingly because of zone-mix:

polyfills.js:7635 Uncaught TypeError: Cannot read property 'eventNames' of undefined
    at eventTargetPatch (polyfills.js:7635)
    at polyfills.js:8003
    at Function.push../node_modules/zone.js/dist/zone-mix.js.Zone.__load_patch (polyfills.js:5274)
    at polyfills.js:8001
    at push../node_modules/zone.js/dist/zone-mix.js.performance (polyfills.js:5185)
    at Object../node_modules/zone.js/dist/zone-mix.js (polyfills.js:5187)
    at __webpack_require__ (runtime.js:84)
    at Module../src/polyfills-electron.ts (polyfills.js:8476)
    at __webpack_require__ (runtime.js:84)
    at Object.1 (polyfills.js:8551)

Taking a look at code, it is calling api.getGlobalObjects() and then accessing .eventNames,

    var _a = api.getGlobalObjects(), eventNames = _a.eventNames, ...

but the definition in effect is from zone-mix.js:644

        getGlobalObjects: function () { return undefined; },

The polyfills file in use for our Electron builds are:

import 'core-js/es7/reflect';
import 'zone.js/dist/zone-mix';  // Included with Angular CLI.
import 'zone.js/dist/zone-patch-electron';

The installed version of zone.js is 0.9.1.

I checked STANDARD-APIS.md and it does still recommend 'zone-mix' for Node-capable Electron builds (nodeIntegration = true). Tried removing zone-patch-electron but there's no change.

Is this still the recommended polyfills.ts setup for Angular apps running in Electron with Node integration turned on?

The error is not present if I opt for zone.js/dist/zone (the standard) as opposed to zone-mix, but I assume I'll only have Zone integration for browser APIs and not Node.js ones, so that's not ideal.

Metadata

Metadata

Assignees

Labels

area: zonesIssues related to zone.js

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions