Skip to content

Commit

Permalink
Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
matteocargnelutti committed Mar 22, 2023
1 parent 1b48322 commit 00e055b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions Scoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,7 @@ export class Scoop {
height: options.captureWindowY
})

// On capture timeout:
// - Disconnect browser
// - Instruct intercepter to stop recording exchanges
// - Set capture state to PARTIAL.
// Enforce capture timeout
const captureTimeoutTimer = setTimeout(() => {
this.log.info(`captureTimeout of ${options.captureTimeout}ms reached. Ending further capture.`)
this.state = Scoop.states.PARTIAL
Expand Down Expand Up @@ -690,6 +687,8 @@ export class Scoop {
try {
const userAgent = await page.evaluate(() => window.navigator.userAgent) // Source user agent from the browser

const timeout = Math.floor((this.options.captureTimeout - headRequestTimeMs) / 1000)

const curlOptions = [
this.url,
'--header', `"User-Agent: ${userAgent}"`,
Expand All @@ -699,10 +698,10 @@ export class Scoop {
'--location',
// This will be the only capture step running:
// use all available time - time spent on first request
'--max-time', Math.floor((this.options.captureTimeout - headRequestTimeMs) / 1000)
'--max-time', timeout
]

await exec('curl', curlOptions)
await exec('curl', curlOptions, { timeout })
} catch (err) {
this.log.trace(err)
}
Expand Down
2 changes: 1 addition & 1 deletion intercepters/ScoopProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class ScoopProxy extends ScoopIntercepter {

/**
* Closes the proxy server
* @returns {Primise<void>}
* @returns {Promise<void>}
*/
async teardown () {
this.#connection.close()
Expand Down

0 comments on commit 00e055b

Please sign in to comment.