Skip to content

Commit

Permalink
bug fix : wait one second to get title when new target create
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuken73 committed Jul 17, 2020
1 parent 010f4b2 commit fab8cc3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions app/browser/Browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ class Browser extends EventEmitter {
}
const requestIndex = page.requestMap.get(request);
if(requestIndex === undefined) {
console.error(`response which cannot be mapped with request Map(not added) arrived : Map[${pageIndex}], ${response.url()}`);
console.error(`response which cannot be mapped with request Map(not added) arrived. reload : Map[${pageIndex}], ${response.url()}`);
await page.reload();
return;
}
const requestFname = getFirstStringBySep({str:getLastStringBySep({str: requestUrl, sep: '/'}), sep:'?'});
const metadata = await imageUtil.getMetadata(buff);
Expand Down Expand Up @@ -271,7 +273,13 @@ class Browser extends EventEmitter {
await page.setRequestInterception(false);
console.log(`request resumed![${pageIndex}]`);
},100)

if(title === ''){
console.log('title is empty.');
setTimeout(async () => {
const title = await page.title();
this.emit('titleChanged', {pageIndex, title});
},1000)
}
});

this._setDefaultBrowserEventHandler();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "electron-image-downloader",
"productName": "Image-Downloader",
"version": "0.0.1",
"version": "0.0.2",
"description": "Web browser based image downloader using puppeteer",
"scripts": {
"build": "concurrently \"yarn build-main\" \"yarn build-renderer\"",
Expand Down

0 comments on commit fab8cc3

Please sign in to comment.