Open Hakier opened 7 years ago
Can you supply a reproduction script?
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);
});
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
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 can you pls point to the fix in nightmare-download-manager
. Thanks for all the help!
I think he's talking about this: https://github.com/rosshinkley/nightmare-download-manager/commit/1cbe2eeba9f0af5aba0c8e4fd9d2e8b39522888a
+1, i implemented the the fix at https://github.com/rosshinkley/nightmare-download-manager/commit/1cbe2eeba9f0af5aba0c8e4fd9d2e8b39522888a and i am still having the same issue.
It would be great if this can be fixed in the inline plugin. I'm suffering from this as well...
this was fixed?
Has anyone been able to solve this?
Any update on this?
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!