When I click the cancel button in the file open dialog box (code below), I get the following error:
A JavaScript error occurred in the main process
Uncaught Exception:
TypeError: Error processing argument -1.
at TypeError (native)
at [object Object].Object.defineProperty.set (/Applications/Electron.app/Contents/Resources/atom.asar/browser/api/lib/web-contents.js:92:24)
at main.js:37:20
at Function.wrappedCallback (/Applications/Electron.app/Contents/Resources/atom.asar/browser/api/lib/dialog.js:80:16)
The error is presented as a modal popup:

I have tested only on Mac so far.
My code is as follows:
The main code for the process that handles the creation of the dialog box is as follows:
import electron, { ipcMain } from 'electron'
const app = electron.app
const BrowserWindow = electron.BrowserWindow
electron.crashReporter.start()
let mainWindow = null
app.on('window-all-closed', () => {
if (process.platform != 'darwin') app.quit()
})
app.on('ready', () => {
mainWindow = new BrowserWindow({
width: 800,
height: 600
})
mainWindow.loadURL(`file:`)
mainWindow.webContents.openDevTools()
mainWindow.on('closed', () => {
mainWindow = null
})
ipcMain.on('file:open', (e, arg) => {
electron.dialog.showOpenDialog(mainWindow, {
properties: ['openFile'],
filters: [{
name: 'Outlines',
extensions: ['pxo']
}]
}, (filePathList) => {
debugger
e.returnValue = filePathList
})
})
})
My debugger instruction has never been reached. In addition, the code works fine when some files are actually selected, and only crashes when you click cancel.
The code (ES6 + JSX) causing the IPC call is as follows:
class Welcome extends React.Component {
render() {
const styles = this.getStyles()
return (
<div style={styles.outerContainer}>
<a style={styles.btnSetLink} onClick={this.initFileSelection.bind(this)}>
Open File
</a>
</div>
)
}
initFileSelection() {
const filePathList = ipcRenderer.sendSync('file:open')
}
...
The code is processed through babel 6. Mine .babelrclooks like this:
{
"presets": ["react", "es2015"]
}
Electronic version: v0.35.1.
Babel dependency versions:
βββ¬ babel-preset-es2015@6.3.13
β βββ babel-plugin-check-es2015-constants@6.3.13
β βββ babel-plugin-transform-es2015-arrow-functions@6.3.13
β βββ babel-plugin-transform-es2015-block-scoped-functions@6.3.13
β βββ¬ babel-plugin-transform-es2015-block-scoping@6.3.13
β β βββ¬ babel-template@6.3.13
β β β βββ babylon@6.3.18
β β βββ¬ babel-traverse@6.3.19
β β β βββ babylon@6.3.18
β β β βββ globals@8.15.0
β β β βββ¬ repeating@1.1.3
β β β βββ¬ is-finite@1.0.1
β β β βββ number-is-nan@1.0.0
β β βββ¬ babel-types@6.3.18
β β βββ esutils@2.0.2
β β βββ to-fast-properties@1.0.1
β βββ¬ babel-plugin-transform-es2015-classes@6.3.15
β β βββ babel-helper-define-map@6.3.13
β β βββ babel-helper-function-name@6.3.15
β β βββ babel-helper-optimise-call-expression@6.3.13
β β βββ babel-helper-replace-supers@6.3.13
β β βββ babel-messages@6.3.18
β βββ babel-plugin-transform-es2015-computed-properties@6.3.13
β βββ babel-plugin-transform-es2015-destructuring@6.3.15
β βββ babel-plugin-transform-es2015-for-of@6.3.13
β βββ babel-plugin-transform-es2015-function-name@6.3.19
β βββ babel-plugin-transform-es2015-literals@6.3.13
β βββ¬ babel-plugin-transform-es2015-modules-commonjs@6.3.16
β β βββ babel-plugin-transform-strict-mode@6.3.13
β βββ babel-plugin-transform-es2015-object-super@6.3.13
β βββ¬ babel-plugin-transform-es2015-parameters@6.3.18
β β βββ¬ babel-helper-call-delegate@6.3.13
β β β βββ babel-helper-hoist-variables@6.3.13
β β βββ babel-helper-get-function-arity@6.3.13
β βββ babel-plugin-transform-es2015-shorthand-properties@6.3.13
β βββ babel-plugin-transform-es2015-spread@6.3.14
β βββ¬ babel-plugin-transform-es2015-sticky-regex@6.3.13
β β βββ babel-helper-regex@6.3.13
β βββ babel-plugin-transform-es2015-template-literals@6.3.13
β βββ babel-plugin-transform-es2015-typeof-symbol@6.3.13
β βββ¬ babel-plugin-transform-es2015-unicode-regex@6.3.13
β β βββ¬ regexpu@1.3.0
β β βββ esprima@2.7.1
β β βββ¬ recast@0.10.33
β β β βββ ast-types@0.8.12
β β β βββ esprima-fb@15001.1001.0-dev-harmony-fb
β β βββ regenerate@1.2.1
β β βββ regjsgen@0.2.0
β β βββ¬ regjsparser@0.1.5
β β βββ jsesc@0.5.0
β βββ¬ babel-plugin-transform-regenerator@6.3.18
β βββ babel-core@6.3.17
β βββ babel-plugin-syntax-async-functions@6.3.13
β βββ babylon@6.3.18
β βββ private@0.1.6
βββ¬ babel-preset-react@6.3.13
β βββ babel-plugin-syntax-flow@6.3.13
β βββ babel-plugin-syntax-jsx@6.3.13
β βββ babel-plugin-transform-flow-strip-types@6.3.15
β βββ babel-plugin-transform-react-display-name@6.3.13
β βββ¬ babel-plugin-transform-react-jsx@6.3.13
β β βββ babel-helper-builder-react-jsx@6.3.13
β βββ babel-plugin-transform-react-jsx-source@6.3.13
βββ¬ babel-register@6.3.13
β βββ¬ babel-core@6.3.17
β β βββ¬ babel-code-frame@6.3.13
β β β βββ¬ chalk@1.1.1
β β β β βββ ansi-styles@2.1.0
β β β β βββ escape-string-regexp@1.0.3
β β β β βββ¬ has-ansi@2.0.0
β β β β β βββ ansi-regex@2.0.0
β β β β βββ strip-ansi@3.0.0
β β β β βββ supports-color@2.0.0
β β β βββ js-tokens@1.0.1
β β β βββ¬ line-numbers@0.2.0
β β β βββ left-pad@0.0.3
β β βββ¬ babel-generator@6.3.19
β β β βββ¬ detect-indent@3.0.1
β β β β βββ get-stdin@4.0.1
β β β β βββ minimist@1.2.0
β β β βββ is-integer@1.0.6
β β β βββ trim-right@1.0.1
β β βββ babel-helpers@6.3.13
β β βββ babylon@6.3.18
β β βββ convert-source-map@1.1.2
β β βββ¬ debug@2.2.0
β β β βββ ms@0.7.1
β β βββ json5@0.4.0
β β βββ¬ minimatch@2.0.10
β β β βββ¬ brace-expansion@1.1.2
β β β βββ balanced-match@0.3.0
β β β βββ concat-map@0.0.1
β β βββ path-is-absolute@1.0.0
β β βββ shebang-regex@1.0.0
β β βββ slash@1.0.0
β β βββ source-map@0.5.3
β βββ babel-runtime@5.8.34
β βββ core-js@1.2.6
β βββ¬ home-or-tmp@1.0.0
β β βββ os-tmpdir@1.0.1
β β βββ user-home@1.1.1
β βββ lodash@3.10.1
β βββ path-exists@1.0.0
β βββ¬ source-map-support@0.2.10
β βββ¬ source-map@0.1.32
β βββ amdefine@1.0.0
, , .