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

Error: Object has been destroyed during download

Open Hakier opened this issue 8 years ago • 11 comments

Hello, I have utilized Your library to download files from one website, many of files can be downloaded but some fails with error listed below. Do You have any suggestions how to debug/fix this issue?

Thank You!

  nightmare queueing action "visible" +23ms
  nightmare running +0ms
  nightmare:actions .visible() for [nid="16616"] a[href^="/code_download"] +0ms
  nightmare queueing action "click" +11ms
  nightmare queueing action "download" +0ms
  nightmare running +0ms
  nightmare:actions .click() on [nid="16616"] a[href^="/code_download"] +0ms
  nightmare:log will-navigate +26ms [{},"https://www.packtpub.com/code_download/16617"]
  nightmare:log did-start-loading +1ms [{}]
  nightmare:log waiting for window to load... +2ms
  nightmare:log did-get-redirect-request +220ms [{},"https://www.packtpub.com/code_download/16617","http://d2mjco6wb7ylug.cloudfront.net/9781783281770-SOCIAL_MEDIA_MINING_WITH_R/9781783281770_code.zip?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cDpcL1wvZDJtamNvNndiN3lsdWcuY2xvdWRmcm9udC5uZXRcLzk3ODE3ODMyODE3NzAtU09DSUFMX01FRElBX01JTklOR19XSVRIX1JcLzk3ODE3ODMyODE3NzBfY29kZS56aXAiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE0Nzg2MjMxNjR9fX1dfQ__&Signature=DN4r5p2hymSGZlXyMtcwD8W279-bEMGKJtJLeFhuZg4fRPJHWATOZMubwXiKha8LcvGigDmn9Zgz4BxlS5ZmsoTNQN4ioEWSWSbmomFLSVUnODDuiqNie0gEfRj756NLWCXlbBvXI-omBSQJ5FClOOCAYQa2Z0t1nTftoHMijf0_&Key-Pair-Id=APKAJTJLPJQL5PVZ47FA",true,302,"GET","https://www.packtpub.com/account/my-ebooks",{"cache-control":["store, no-cache, must-revalidate","post-check=0, pre-check=0"],"connection":["keep-alive"],"content-length":["0"],"content-type":["text/html; charset=utf-8"],"date":["Tue, 08 Nov 2016 16:30:04 GMT"],"expires":["Sun, 19 Nov 1978 05:00:00 GMT"],"last-modified":["Tue, 08 Nov 2016 16:29:24 GMT"],"location":["http://d2mjco6wb7ylug.cloudfront.net/9781783281770-SOCIAL_MEDIA_MINING_WITH_R/9781783281770_code.zip?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cDpcL1wvZDJtamNvNndiN3lsdWcuY2xvdWRmcm9udC5uZXRcLzk3ODE3ODMyODE3NzAtU09DSUFMX01FRElBX01JTklOR19XSVRIX1JcLzk3ODE3ODMyODE3NzBfY29kZS56aXAiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE0Nzg2MjMxNjR9fX1dfQ__&Signature=DN4r5p2hymSGZlXyMtcwD8W279-bEMGKJtJLeFhuZg4fRPJHWATOZMubwXiKha8LcvGigDmn9Zgz4BxlS5ZmsoTNQN4ioEWSWSbmomFLSVUnODDuiqNie0gEfRj756NLWCXlbBvXI-omBSQJ5FClOOCAYQa2Z0t1nTftoHMijf0_&Key-Pair-Id=APKAJTJLPJQL5PVZ47FA"],"server":["nginx/1.4.5"]}]
  nightmare:log did-get-response-details +46ms [{},false,"http://d2mjco6wb7ylug.cloudfront.net/9781783281770-SOCIAL_MEDIA_MINING_WITH_R/9781783281770_code.zip?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cDpcL1wvZDJtamNvNndiN3lsdWcuY2xvdWRmcm9udC5uZXRcLzk3ODE3ODMyODE3NzAtU09DSUFMX01FRElBX01JTklOR19XSVRIX1JcLzk3ODE3ODMyODE3NzBfY29kZS56aXAiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE0Nzg2MjMxNjR9fX1dfQ__&Signature=DN4r5p2hymSGZlXyMtcwD8W279-bEMGKJtJLeFhuZg4fRPJHWATOZMubwXiKha8LcvGigDmn9Zgz4BxlS5ZmsoTNQN4ioEWSWSbmomFLSVUnODDuiqNie0gEfRj756NLWCXlbBvXI-omBSQJ5FClOOCAYQa2Z0t1nTftoHMijf0_&Key-Pair-Id=APKAJTJLPJQL5PVZ47FA","https://www.packtpub.com/code_download/16617",200,"GET","",{"accept-ranges":["bytes"],"age":["5372"],"connection":["keep-alive"],"content-length":["9996"],"content-type":["application/zip"],"date":["Tue, 08 Nov 2016 15:00:15 GMT"],"etag":["\"34b6ccd69f999405a1554c99f2266287\""],"last-modified":["Fri, 20 Nov 2015 12:03:36 GMT"],"server":["AmazonS3"],"via":["1.1 be44153b726c8e1387911c4a5f2e2e4b.cloudfront.net (CloudFront)"],"x-amz-cf-id":["Hmj758bb8y9rLyDAbXpdh1zQ8y9sIAQAiVs-35TPPcghyctVPQgbAw=="],"x-amz-meta-s3cmd-attrs":["uid:80/gname:www/uname:www/gid:80/mode:33204/mtime:1395230384/atime:1447721928/ctime:1395230385"],"x-cache":["Hit from cloudfront"]},"mainFrame"]
  nightmare:log waiting, elapsed: 0 +2ms
  nightmare:log did-fail-provisional-load +1ms [{},-3,"ERR_ABORTED","http://d2mjco6wb7ylug.cloudfront.net/9781783281770-SOCIAL_MEDIA_MINING_WITH_R/9781783281770_code.zip?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cDpcL1wvZDJtamNvNndiN3lsdWcuY2xvdWRmcm9udC5uZXRcLzk3ODE3ODMyODE3NzAtU09DSUFMX01FRElBX01JTklOR19XSVRIX1JcLzk3ODE3ODMyODE3NzBfY29kZS56aXAiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE0Nzg2MjMxNjR9fX1dfQ__&Signature=DN4r5p2hymSGZlXyMtcwD8W279-bEMGKJtJLeFhuZg4fRPJHWATOZMubwXiKha8LcvGigDmn9Zgz4BxlS5ZmsoTNQN4ioEWSWSbmomFLSVUnODDuiqNie0gEfRj756NLWCXlbBvXI-omBSQJ5FClOOCAYQa2Z0t1nTftoHMijf0_&Key-Pair-Id=APKAJTJLPJQL5PVZ47FA",true]
  nightmare:log did-stop-loading +0ms [{}]
  nightmare:log window became ready: https://www.packtpub.com/account/my-ebooks +0ms
  nightmare:log will-download +99ms
Nightmare runner error:

        Error: Object has been destroyed
            at Error (native)
            at Timeout.wait [as _onTimeout] (eval at <anonymous> (/home/hakier/dev/projects/js/crawler/node_modules/nightmare/lib/runner.js:542:14), <anonymous>:54:28)
            at tryOnTimeout (timers.js:232:11)
            at Timer.listOnTimeout (timers.js:202:5)

Hakier avatar Nov 08 '16 16:11 Hakier

Can you supply a reproduction script?

rosshinkley avatar Nov 20 '16 17:11 rosshinkley

I have created templorary account for this puprose. Below is code that tryes to download zip file. It is odd that it only fails on zip files and it is not for all of them, but example below will fail every time. I have castrated example as much as I could.

Let me know if You need anything from me.

npm install nightmare nightmare-inline-download


const Nightmare = require('nightmare');
require('nightmare-inline-download')(Nightmare);

const nightmare = Nightmare({
    // show: true,
    // openDevTools: true,
    waitTimeout: 3600000,
    gotoTimeout: 3600000,
    loadTimeout: 3600000,
    executionTimeout: 3600000,
});
const fs = require('fs');
const request = require('request');
const selectors = {
    logout: '#account-bar-logged-in a[href="/logout"]',
    showLoginForm: '#account-bar-login-register .login-popup',
    loginForm: {
        email: '#account-bar-form-login #email',
        password: '#account-bar-form-login #password',
        submit: '#login-form-submit input',
    },
    myAccount: {
        root: '#account-bar-logged-in a[href="/account"]',
        myEbooks: 'a[href="/account/my-ebooks"]',
    }
};
const credentials = {
    email: '[email protected]',
    password: 'kolp{:}"',
};

nightmare
        .goto('http://www.packtpub.com/packt/offers/free-learning')
        .visible(selectors.myAccount.root)
        .then(isAuthenticated => {
            !isAuthenticated && console.log('authenticating...');

            return !isAuthenticated && nightmare
                            .click(selectors.showLoginForm)
                            .wait(selectors.loginForm.email)
                            .type(selectors.loginForm.email, credentials.email)
                            .type(selectors.loginForm.password, credentials.password)
                            .click(selectors.loginForm.submit)
                            .wait(selectors.myAccount.root);
        })
        .then(() => !console.log('visiting my account...') && nightmare.wait(selectors.myAccount.root).click(selectors.myAccount.root))
        .then(() => !console.log('visiting my ebooks...') && nightmare.wait(selectors.myAccount.myEbooks).click(selectors.myAccount.myEbooks))
        .then(() => {
            console.log('expanding ebook info...');

            const selector = '[nid="12730"]';

            return nightmare.visible(selector)
                    .then(isClickable => isClickable && nightmare.click(selector))
                    .then(() => {
                        console.log('downloading ebook...');

                        const filename = './tmp.zip';
                        const selector = '[nid="12730"] a[href^="/code_download"]';

                        return nightmare.visible(selector).then(isClickable => isClickable && nightmare.click(selector).download(filename));
                    });
        })
        .then(() => nightmare.end())
        .catch(function (error) {
            console.error('Failed:', error);
        });

Hakier avatar Nov 22 '16 11:11 Hakier

Hi, I have the same error since 3 days (no problem before) It's happening only when i try on my docker container on digital ocean (1go et 1cpu) I can't catch the error correctly even if i do :

		try {
			debug('Trying to download....')
			await nightmare.click('a[title="click here"]')
			debug('After click')
			const downloaded = await nightmare.download('/tmp/file' + started_at + '.pdf')
			debug('Downloaded !! ')
			downloaded.type = 'file'
			downloaded.filename = 'results-' + started_at + '.pdf'
			debug('Downloaded : ', downloaded)
		}
		catch (ex) {
			debug('Download failed')
			sendError(ex)
		}

The process is killed and my webapp restart...

@Hakier : did you manage to solve your problem ?

Thanks !

EDIT : related to https://github.com/rosshinkley/nightmare-download-manager/issues/14

GautierT avatar Mar 07 '17 22:03 GautierT

Yeah, there's a fix for this in nightmare-download-manager that I don't think I ported to this library. I will put it on my todo list. The issue has to do with extremely small/fast downloads finishing before the management machinery can handle them so Electron disposes the download event.

rosshinkley avatar Mar 10 '17 20:03 rosshinkley

@rosshinkley can you pls point to the fix in nightmare-download-manager. Thanks for all the help!

SantoshSrinivas79 avatar Mar 15 '17 05:03 SantoshSrinivas79

I think he's talking about this: https://github.com/rosshinkley/nightmare-download-manager/commit/1cbe2eeba9f0af5aba0c8e4fd9d2e8b39522888a

drawyan avatar Apr 25 '17 14:04 drawyan

+1, i implemented the the fix at https://github.com/rosshinkley/nightmare-download-manager/commit/1cbe2eeba9f0af5aba0c8e4fd9d2e8b39522888a and i am still having the same issue.

L422Y avatar Jun 08 '17 22:06 L422Y

It would be great if this can be fixed in the inline plugin. I'm suffering from this as well...

mariodavid avatar Jul 02 '17 17:07 mariodavid

this was fixed?

djalmaaraujo avatar Jun 07 '18 03:06 djalmaaraujo

Has anyone been able to solve this?

cagdasdag avatar Mar 12 '19 19:03 cagdasdag

Any update on this?

ca-simone-chiorazzo avatar Apr 26 '19 09:04 ca-simone-chiorazzo