Electron Forge Error - cannot read property 'close' of undefined - javascript

I just set up a basic electron-react app by using electron-forge and adding React+webpack+typescript per instructions and it all works great (I haven't added anything beyond the basic setup). It compiles well with all green checkboxes.
However, when I hit the close button by mouse clicking the x in the top right, it shuts down but gives the following error:
An unhandled exception has occurred inside Forge:
Cannot read property 'close' of undefined
TypeError: Cannot read property 'close' of undefined
at WebpackPlugin.exitHandler (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\#electron-forge\plugin-webpack\src\WebpackPlugin.ts:83:16)
at ChildProcess.<anonymous> (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\#electron-forge\plugin-webpack\src\WebpackPlugin.ts:171:18)
at ChildProcess.emit (events.js:412:35)
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\#electron-forge\plugin-webpack\dist\WebpackPlugin.js:87
server.close();
^
TypeError: Cannot read property 'close' of undefined
at WebpackPlugin.exitHandler (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\#electron-forge\plugin-webpack\src\WebpackPlugin.ts:83:16)
at process.<anonymous> (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\#electron-forge\plugin-webpack\src\WebpackPlugin.ts:126:40)
at process.emit (events.js:412:35)
at process.emit (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\source-map-support\source-map-support.js:516:21)
at processEmit [as emit] (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\signal-exit\index.js:155:35)
at process.exit (internal/process/per_thread.js:169:15)
at process.<anonymous> (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\#electron-forge\cli\src\util\terminate.ts:20:11)
at process.emit (events.js:400:28)
at process.emit (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\source-map-support\source-map-support.js:516:21)
at processEmit [as emit] (C:\Users\cwebb\Documents\Webdev\Atlas\node_modules\signal-exit\index.js:161:32)
at process._fatalException (internal/process/execution.js:167:25)
Any recommendations as to how to correct this? I found one answer on a gitmemory site but it just said "thanks it worked" but no comment about how to fix the problem.
Thank you in advance for your help.

I just ran into this today and managed to find a hint here
You have to bind to the Electron app's window-all-closed event if you don't want this to happen. Usually, you'd use this event to quit the app when all the windows are closed. Here's an example snippet from main.js:
const { app } = require('electron')
app.on('window-all-closed', () => {
app.quit()
})
If you want the app to keep running after you close all windows, you can remove the call to app.quit, but make sure to keep the binding to window-all-closed. Having the binding prevents the exception from being thrown.

Related

Why is the vanilla JS example for RxDB not working

I've followed the instructions at GitHub, but the example doesn't work.
The app shows "Starting database".
At the browser console there is this error:
Uncaught (in promise) TypeError: storage is undefined
_callee6$ http://127.0.0.1:20202/dist/rxdb.browserify.js:11032
tryCatch http://127.0.0.1:20202/dist/rxdb.browserify.js:70936
invoke http://127.0.0.1:20202/dist/rxdb.browserify.js:71167
defineIteratorMethods http://127.0.0.1:20202/dist/rxdb.browserify.js:70992
asyncGeneratorStep http://127.0.0.1:20202/dist/rxdb.browserify.js:14068
_next http://127.0.0.1:20202/dist/rxdb.browserify.js:14090
_asyncToGenerator http://127.0.0.1:20202/dist/rxdb.browserify.js:14097
_asyncToGenerator http://127.0.0.1:20202/dist/rxdb.browserify.js:14086
_createRxDatabaseStorageInstances http://127.0.0.1:20202/dist/rxdb.browserify.js:11060
createRxDatabaseStorageInstances http://127.0.0.1:20202/dist/rxdb.browserify.js:11017
_callee7$ http://127.0.0.1:20202/dist/rxdb.browserify.js:11075
tryCatch http://127.0.0.1:20202/dist/rxdb.browserify.js:70936
invoke http://127.0.0.1:20202/dist/rxdb.browserify.js:71167
defineIteratorMethods http://127.0.0.1:20202/dist/rxdb.browserify.js:70992
asyncGeneratorStep http://127.0.0.1:20202/dist/rxdb.browserify.js:14068
_next http://127.0.0.1:20202/dist/rxdb.browserify.js:14090
_asyncToGenerator http://127.0.0.1:20202/dist/rxdb.browserify.js:14097
_asyncToGenerator http://127.0.0.1:20202/dist/rxdb.browserify.js:14086
_prepare http://127.0.0.1:20202/dist/rxdb.browserify.js:11104
prepare http://127.0.0.1:20202/dist/rxdb.browserify.js:11064
createRxDatabase http://127.0.0.1:20202/dist/rxdb.browserify.js:11142
<anonymous> http://127.0.0.1:20202/main.js:33
When I try to add a hero and click the "Insert" button this error appears at the console:
Uncaught ReferenceError: col is not defined
addHero http://127.0.0.1:20202/main.js:97
onclick http://127.0.0.1:20202/:1
Ist this a bug or am I missing something?
According to the rxdb v10 release notes:
"...many (example projects) are outdated and need updates."
I was as well not able to get it working.

Getting error on gatsby build command: TypeError: Unexpected response from worker: undefined

I am getting this error when I run the command $ gatsby build on the terminal.
What gets my attention on this one is that it mentions jest-worker, and I don't see that module on my package.json. I see it only in the node_modules folder.
I already tried many things. Deleting node_modules, package_lock.json, npm cache clean --force and some other things.
I can't find these errors on the internet either.
If I keep scrolling down on the terminal, the error ends with this:
/Users/marcelo/Work/SM/gatsby-on-demand/node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
throw ex;
^
Error: write EPIPE
at process.target._send (internal/child_process.js:806:20)
at process.target.send (internal/child_process.js:676:19)
at /Users/marcelo/Work/SM/gatsby-on-demand/node_modules/gatsby-cli/lib/reporter/loggers/ipc/index.js:58:13
at dispatch (/Users/marcelo/Work/SM/gatsby-on-demand/node_modules/gatsby-cli/lib/reporter/redux/index.js:54:5)
at Object.createLog (/Users/marcelo/Work/SM/gatsby-on-demand/node_modules/redux/lib/redux.js:483:12)
at Reporter.log (/Users/marcelo/Work/SM/gatsby-on-demand/node_modules/gatsby-cli/lib/reporter/reporter.js:173:40)
at Object.console.log (/Users/marcelo/Work/SM/gatsby-on-demand/node_modules/gatsby-cli/lib/reporter/patch-console.js:17:14)
at WithHeaderLayout (/Users/marcelo/Work/SM/gatsby-on-demand/public/render-page.js:104712:376)
at d (/Users/marcelo/Work/SM/gatsby-on-demand/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:36:498)
at $a (/Users/marcelo/Work/SM/gatsby-on-demand/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:39:16)
at a.b.render (/Users/marcelo/Work/SM/gatsby-on-demand/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:476)
at a.b.read (/Users/marcelo/Work/SM/gatsby-on-demand/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:18)
at renderToString (/Users/marcelo/Work/SM/gatsby-on-demand/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:54:364)
at Module.default (/Users/marcelo/Work/SM/gatsby-on-demand/public/render-page.js:710:28)
at /Users/marcelo/Work/SM/gatsby-on-demand/node_modules/gatsby/dist/utils/worker/render-html.js:28:36
at Promise._execute (/Users/marcelo/Work/SM/gatsby-on-demand/node_modules/bluebird/js/release/debuggability.js:384:9)
Emitted 'error' event on process instance at:
at processEmit [as emit] (/Users/marcelo/Work/SM/gatsby-on-demand/node_modules/signal-exit/index.js:161:32)
at internal/child_process.js:810:39
at processTicksAndRejections (internal/process/task_queues.js:75:11) {
errno: 'EPIPE',
code: 'EPIPE',
syscall: 'write'
}
I've been going through this the whole day.
Any ideas?

Tests not running in Testcafe getting error 'TypeError: Cannot read property 'split' of undefined'

New to TestCafe .. just copied the code from their site and executed it.
import { Selector } from 'testcafe';
fixture `Getting Started`
.page `http://devexpress.github.io/testcafe/example`;
test('My first test', async t => {
await t
.typeText('#developer-name', 'John Smith')
.click('#submit-button');
});
The browsers are connected successfully but script is not executed and got error after some time
Nimits-MacBook-Pro:TestCafe nimit$ testcafe chrome demo.js
ERROR Was unable to open the browser "chrome:" due to error.
TypeError: Cannot read property 'split' of undefined
at Object.callee$0$0$ (/usr/local/lib/node_modules/testcafe/node_modules/testcafe-browser-tools/lib/api/find-window.js:111:36)
at tryCatch (/usr/local/lib/node_modules/testcafe/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:72:40)
at Generator.invoke [as _invoke] (/usr/local/lib/node_modules/testcafe/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:334:22)
at Generator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/testcafe/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:105:21)
at tryCatch (/usr/local/lib/node_modules/testcafe/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:72:40)
at invoke (/usr/local/lib/node_modules/testcafe/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:146:20)
at /usr/local/lib/node_modules/testcafe/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:154:13
Environment
nodejs version - 10.16.0
npm - 6.9.0
OS - MACOS catalina
TestCafe - 1.6.0

How do I add additional data to Cypress failures?

I would like to log additional data when a test case fails. Where can I best insert my custom error handler?
For example:
cy.get('something')
.should('have.property', 'blah')
When this fails in the Cypress dashboard, I get:
CypressError: Timed out retrying: expected 'something' to have a property 'blah'
at Object.cypressErr (https://my.website.com/__cypress/runner/cypress_runner.js:65727:11)
at Object.throwErr (https://my.website.com/__cypress/runner/cypress_runner.js:65692:18)
at Object.throwErrByPath (https://my.website.com/__cypress/runner/cypress_runner.js:65719:17)
at retry (https://my.website.com/__cypress/runner/cypress_runner.js:59237:16)
at https://my.website.com/__cypress/runner/cypress_runner.js:51312:18
at tryCatcher (https://my.website.com/__cypress/runner/cypress_runner.js:131273:23)
at Promise._settlePromiseFromHandler (https://my.website.com/__cypress/runner/cypress_runner.js:129291:31)
at Promise._settlePromise (https://my.website.com/__cypress/runner/cypress_runner.js:129348:18)
at Promise._settlePromise0 (https://my.website.com/__cypress/runner/cypress_runner.js:129393:10)
at Promise._settlePromises (https://my.website.com/__cypress/runner/cypress_runner.js:129468:18)
at Async._drainQueue (https://my.website.com/__cypress/runner/cypress_runner.js:126197:16)
at Async._drainQueues (https://my.website.com/__cypress/runner/cypress_runner.js:126207:10)
at Async.drainQueues (https://my.website.com/__cypress/runner/cypress_runner.js:126081:14)
at <anonymous>
What I can do to customize this error, to something like:
CypressError: ...
My additional logging: {foo: 'bar', etc, etc}
Ultimately, I want to log some additional contextual data, so I can investigate + debug why a test may be failing/flaking.
I hope this library helps your need - https://github.com/cypress-io/error-message
Here is a gist out of it,
//Load the function from the module
const {formErrorText} = require('#cypress/error-message')
//Handle the error with custome messages
const fileSaveError = {
description: 'We could not save an important file',
solution: `Please check folder permissions and try again
more details on our FAQ page: https://faq.company.name
`
}
fs.writeFile(name)
.catch(
formErrorText(info).then(console.error)
)
/*
shows nice error message
------
We could not save an important file
Please check folder permissions and try again
more details on our FAQ page: https://faq.company.name
Exception message
------
Platform: darwin
Version: 15.6.2
*/
For more information, you can check this blog - https://www.cypress.io/blog/2017/07/26/good-error-messages/#Useful-E2E-assertion-failures
Edit 1:
As stated in comment, if you are looking for handling the mysterious failures, would suggest you to take a look at Cypress event handling mechanism. Here is the excerpt of it,
// likely want to do this in a support file
// so it's applied to all spec files
// cypress/support/index.js
Cypress.on('uncaught:exception', (err, runnable) => {
// Handle your logging logic here
})

gulp-angular-templatecache throwing error when piping angular templates

I'm having some difficulty with gulp-angular-templatecache. I have a gulpfile with a task:
gulp.task('templates', function() {
return gulp.src(paths.angularTemplates)
.pipe(templateCache())
/*.pipe(gulp.dest('javascript/angular'))*/;
});
I'm not sure why but the following error is thrown when piping to gulp-angular-templatecache and throws:
stream.js:74
throw er; // Unhandled stream error in pipe.
^
TypeError: Cannot read property 'toString' of null
at templateCacheFile (/home/vagrant/app/node_modules/gulp-angular-templatecache/index.js:89:40)
at wrappedMapper (/home/vagrant/app/node_modules/gulp-angular-templatecache/node_modules/event-stream/node_modules/map-stream/index.js:84:19)
at Stream.stream.write (/home/vagrant/app/node_modules/gulp-angular-templatecache/node_modules/event-stream/node_modules/map-stream/index.js:96:21)
at Stream.method [as write] (/home/vagrant/app/node_modules/gulp-angular-templatecache/node_modules/event-stream/node_modules/duplexer/index.js:47:39)
at write (/home/vagrant/app/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
at flow (/home/vagrant/app/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)
at DestroyableTransform.pipeOnReadable (/home/vagrant/app/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:664:5)
at emitNone (events.js:67:13)
at DestroyableTransform.emit (events.js:166:7)
at emitReadable_ (/home/vagrant/app/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:448:10)
I'm not sure what problem this error is related to. Any help would be greatly appreciated.
Many thanks.
there was a newer gulp-angular-templatecache version which broke the it. Ended up specifying a specific version in the gulpfile
In my project this was caused by a folder name with a dot inside.
So, I had a folder called folder_name.html and had to rename it to folder_name.
(Using gulp-angular-templatecache version 1.9.1)

Categories

Resources