nightmare-download-manager icon indicating copy to clipboard operation
nightmare-download-manager copied to clipboard

Nightmare runner error:Error: Object has been destroyed

Open GautierT opened this issue 7 years ago • 12 comments

Hi ! When using this package if after a download i don't end nightmare i have this crash. Here is the full log. How can i catch this error ? And how to fix it ? Thanks for your work on nightmare @rosshinkley

  nightmare queueing action "waitDownloadsComplete" +0ms
  nightmare running +0ms
  nightmare:download-manager waitDownloadsComplete waiting for downloads to finish +0ms
  nightmare:download-manager download AffichageResultats.pdf is updated: 0.00% +0ms
  nightmare:download-manager download AffichageResultats.pdf is updated: 0.00% +0ms
  nightmare:log waiting, elapsed: 100 +100ms
  nightmare:log waiting, elapsed: 200 +104ms
  nightmare:download-manager download AffichageResultats.pdf is updated: 100.00% +4ms
  nightmare:download-manager download AffichageResultats.pdf is updated: 100.00% +1ms
  nightmare:download-manager download AffichageResultats.pdf is updated: 100.00% +0ms
  app:scripts Download Completed ! +35ms
  app:scripts Putting in array.... +0ms
  nightmare:download-manager download AffichageResultats.pdf is completed: 100.00% +1ms
  nightmare:log waiting, elapsed: 300 +60ms

  .......... a lot of  nightmare:log waiting, elapsed: 4800 +106ms ...............

  nightmare:log waiting, elapsed: 4800 +106ms
  nightmare:log waiting, elapsed: 4900 +106ms
  nightmare:download-manager download AffichageResultats.pdf is force-cancelled: 0.00% +101ms
  nightmare:log no parent request received for download, discarding +1ms
Nightmare runner error:

	Error: Object has been destroyed
	    at Error (native)
	    at Timeout.wait [as _onTimeout] (eval at <anonymous> (/Users/gautier/Documents/Projets/lifebox/server/node_modules/nightmare/lib/runner.js:543:14), <anonymous>:89:35)
	    at tryOnTimeout (timers.js:232:11)
	    at Timer.listOnTimeout (timers.js:202:5)

Snippet :

debug('Trying to download....')
await nightmare.click('a[title="click here"]')
debug('After click')
await nightmare.waitDownloadsComplete()
nightmare.on('download', async (state, downloadItem) => {
	try {
		if (state === 'started') {
			nightmare.emit('download', '/tmp/resultats-' + started_at + '.pdf', downloadItem)
		}
		else if (state === 'completed') {
			debug('Download Completed !')
			debug('Putting in array....')
			files_store.push({
				type: 'file',
				filename: 'resultats-' + started_at + '.pdf',
				path: '/tmp/resultats-' + started_at + '.pdf',
				mimetype: downloadItem.mimetype
			})
			debug('Downloaded : ', downloadItem)
		}
	}
	catch(ex){
		debug('ex in download : ', ex);
	}
})

GautierT avatar Mar 08 '17 11:03 GautierT

Sometimes, if the files are very small, the download will complete prior to the download pausing, which can cause problems as the underlying Electron event is already disposed. When the download manager attempts to resume the completed download, it's trying to hit a disposed object, and Electron crashes. It's a similar problem to the referenced Nightmare issue with a slightly different cause.

I thought I had all of the edge cases for this caught - when the download manager responds with how to handle the download, and if the download is complete, the manager should simply move the file and ignore the download object from Electron entirely.

Do you have a minimum repro where this still happens?

rosshinkley avatar Mar 10 '17 20:03 rosshinkley

Hi @rosshinkley, It's on a private website so i can't make a minimum repro ... 😕 I will try to find you an access.

But in the meantime how can i catch the error ? Why try/catch failed to catch it ? Thanks !

GautierT avatar Mar 15 '17 09:03 GautierT

+1 Any progress here?

Kinzi avatar Jun 28 '17 17:06 Kinzi

+1 getting the same issue

Mine happens only with one wsdl file (CompetitorService.wsdl 10.1 KB ) .. anyone know how ca I avoid this?

atorralb avatar Jun 29 '17 16:06 atorralb

Same issue.

What should we do with this?

mgroshevoy avatar Jul 04 '17 14:07 mgroshevoy

Anybody any idea how to catch this error?

Kinzi avatar Oct 11 '17 07:10 Kinzi

I have same question, anybody know how to solve this problem?

quan-zai avatar Feb 08 '18 08:02 quan-zai

+1 getting the same issue

vijaypatoliya avatar Mar 03 '18 04:03 vijaypatoliya

The solution for me was to install "libgconf-2-4" Since Chrome 42, is a dependency.

just

apt-get install libgconf-2-4

and test if you have troubles, launch your application with:

DEBUG=nightmare*,electron:* node app.js

sebaplaza avatar Mar 29 '18 13:03 sebaplaza

@sebaplaza nope, that does not work. i'm still getting this error on small files.

utkukaratas avatar Apr 11 '18 04:04 utkukaratas

Has anyone been able to solve this?

cagdasdag avatar Mar 12 '19 19:03 cagdasdag

+1 getting the same issue

fingerpich avatar May 22 '19 10:05 fingerpich