@@ -63,24 +63,24 @@ exports.renderView = function(options, cb) {
63
63
} ) ;
64
64
}
65
65
66
- try {
67
- if ( ! chromePath && alternateChrome ) {
68
- chromePath = yield fetchChromeExecutablePath ( ) ;
69
- }
66
+ if ( ! chromePath && alternateChrome ) {
67
+ chromePath = yield fetchChromeExecutablePath ( ) ;
68
+ }
70
69
71
- var settings = {
72
- headless : true ,
73
- args : [ '--no-sandbox' , '--disable-setuid-sandbox' ] ,
74
- ignoreHTTPSErrors : true ,
75
- userDataDir : pathModule . resolve ( __dirname , "../../dump/chrome" )
76
- } ;
70
+ var settings = {
71
+ headless : true ,
72
+ args : [ '--no-sandbox' , '--disable-setuid-sandbox' ] ,
73
+ ignoreHTTPSErrors : true ,
74
+ userDataDir : pathModule . resolve ( __dirname , "../../dump/chrome" )
75
+ } ;
77
76
78
- if ( chromePath ) {
79
- settings . executablePath = chromePath ;
80
- }
77
+ if ( chromePath ) {
78
+ settings . executablePath = chromePath ;
79
+ }
81
80
82
- var browser = yield puppeteer . launch ( settings ) ;
81
+ var browser = yield puppeteer . launch ( settings ) ;
83
82
83
+ try {
84
84
var page = yield browser . newPage ( ) ;
85
85
86
86
page . on ( 'console' , ( msg ) => {
@@ -112,7 +112,7 @@ exports.renderView = function(options, cb) {
112
112
var cbFn = options . cbFn || function ( ) { } ;
113
113
var beforeScrnCbFn = options . beforeScrnCbFn || function ( ) { } ;
114
114
var source = options . source ;
115
- var navigationTimeout = options . timeout || 30000 ;
115
+ var updatedTimeout = options . timeout || 30000 ;
116
116
117
117
options . dimensions = {
118
118
width : options . dimensions && options . dimensions . width ? options . dimensions . width : 1366 ,
@@ -121,27 +121,17 @@ exports.renderView = function(options, cb) {
121
121
scale : options . dimensions && options . dimensions . scale ? options . dimensions . scale : 2
122
122
} ;
123
123
124
- page . setDefaultNavigationTimeout ( navigationTimeout ) ;
124
+ page . setDefaultNavigationTimeout ( updatedTimeout ) ;
125
125
126
126
yield page . goto ( host + '/login/token/' + token + '?ssr=true' ) ;
127
127
128
- try {
129
- yield page . waitForSelector ( 'countly' ) ;
130
- }
131
- catch ( e ) {
132
- //Wait time exceeded
133
- }
128
+ yield page . waitForSelector ( 'countly' , { timeout : updatedTimeout } ) ;
134
129
135
130
yield timeout ( 2000 ) ;
136
131
137
132
yield page . goto ( host + view ) ;
138
133
139
- try {
140
- yield page . waitForSelector ( 'countly' ) ;
141
- }
142
- catch ( e ) {
143
- //Wait time exceeded
144
- }
134
+ yield page . waitForSelector ( 'countly' , { timeout : updatedTimeout } ) ;
145
135
146
136
yield timeout ( 10000 ) ;
147
137
@@ -225,6 +215,7 @@ exports.renderView = function(options, cb) {
225
215
}
226
216
catch ( e ) {
227
217
log . e ( e , e . stack ) ;
218
+ yield browser . close ( ) ;
228
219
throw e ;
229
220
}
230
221
} ) ( ) . then ( function ( response ) {
0 commit comments