diff --git a/packages/goto/package.json b/packages/goto/package.json index 3d2fd41f48..423abef1a8 100644 --- a/packages/goto/package.json +++ b/packages/goto/package.json @@ -31,7 +31,7 @@ "@browserless/devices": "^5.18.5", "@cliqz/adblocker-puppeteer": "~1.5.0", "debug-logfmt": "~1.0.4", - "got": "~9.6.0", + "got": "~10.4.0", "p-reflect": "~2.1.0", "p-timeout": "~3.2.0", "tldts": "~5.6.3" diff --git a/packages/goto/scripts/postinstall.js b/packages/goto/scripts/postinstall.js index bc9364f955..657e7528e8 100644 --- a/packages/goto/scripts/postinstall.js +++ b/packages/goto/scripts/postinstall.js @@ -9,17 +9,12 @@ const writeFile = promisify(fs.writeFile) const OUTPUT_FILENAME = 'src/engine.bin' -// Small helpers to allow fetching different types of data with `got` -const fetchBuffer = async url => (await got(url, { encoding: null })).body -const fetchText = async url => Buffer.from(await fetchBuffer(url), 'ascii') -const fetchJson = async url => JSON.parse(await fetchText(url)) - // Lightweight `fetch` polyfill on top of `got` to allow consumption by adblocker const fetch = url => Promise.resolve({ - text: () => fetchText(url), - arrayBuffer: () => fetchBuffer(url), - json: () => fetchJson(url) + text: () => got(url), + arrayBuffer: () => got(url).buffer(), + json: () => got(url).json() }) const main = async () => { diff --git a/packages/screenshot/package.json b/packages/screenshot/package.json index 1f6e0b2388..60c9940c5a 100644 --- a/packages/screenshot/package.json +++ b/packages/screenshot/package.json @@ -28,7 +28,7 @@ ], "dependencies": { "@browserless/goto": "^5.22.0", - "got": "~9.6.0", + "got": "~10.4.0", "is-url-http": "~1.2.4", "p-reflect": "~2.1.0", "sharp": "~0.24.0", diff --git a/packages/screenshot/src/index.js b/packages/screenshot/src/index.js index ac672f5e4e..961d3fbc41 100644 --- a/packages/screenshot/src/index.js +++ b/packages/screenshot/src/index.js @@ -14,10 +14,7 @@ const BROWSER_THEMES = { } const getBackground = async (bg = 'transparent') => { - if (isHttpUrl(bg)) { - const { body } = await got(bg, { encoding: null }) - return body - } + if (isHttpUrl(bg)) return got(bg).buffer() if (!bg.includes('gradient')) { bg = `linear-gradient(45deg, ${bg} 0%, ${bg} 100%)`