Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Object has been destroyed during download #10

Open
Hakier opened this issue Nov 8, 2016 · 11 comments
Open

Error: Object has been destroyed during download #10

Hakier opened this issue Nov 8, 2016 · 11 comments

Comments

@Hakier
Copy link

Hakier commented Nov 8, 2016

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)
@rosshinkley
Copy link
Owner

Can you supply a reproduction script?

@Hakier
Copy link
Author

Hakier commented Nov 22, 2016

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: 'reg@g.pl',
    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);
        });

@GautierT
Copy link

GautierT commented Mar 7, 2017

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 rosshinkley/nightmare-download-manager#14

@rosshinkley
Copy link
Owner

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.

@SantoshSrinivas79
Copy link

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

@drawyan
Copy link

drawyan commented Apr 25, 2017

I think he's talking about this:
rosshinkley/nightmare-download-manager@1cbe2ee

@L422Y
Copy link

L422Y commented Jun 8, 2017

+1, i implemented the the fix at rosshinkley/nightmare-download-manager@1cbe2ee and i am still having the same issue.

@mariodavid
Copy link

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

@djalmaaraujo
Copy link

this was fixed?

@cagdasdag
Copy link

Has anyone been able to solve this?

@ca-simone-chiorazzo
Copy link

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants