Skip to content

Commit

Permalink
Puppeteer: Upgrade to v22 (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
evictorero authored Aug 23, 2024
1 parent 12fcff3 commit 27928cf
Show file tree
Hide file tree
Showing 12 changed files with 300 additions and 251 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@grpc/grpc-js": "^1.8.22",
"@grpc/proto-loader": "^0.7.2",
"@hapi/boom": "^10.0.0",
"@puppeteer/browsers": "^1.6.0",
"@puppeteer/browsers": "^2.3.1",
"chokidar": "^3.5.2",
"dompurify": "^2.4.0",
"express": "^4.19.2",
Expand All @@ -42,8 +42,8 @@
"on-finished": "^2.3.0",
"poolpeteer": "^0.23.0",
"prom-client": "^14.1.0",
"puppeteer": "^21.0.3",
"puppeteer-cluster": "^0.23.0",
"puppeteer": "^22.8.2",
"puppeteer-cluster": "^0.24.0",
"unique-filename": "^2.0.1",
"winston": "^3.8.2"
},
Expand All @@ -59,7 +59,7 @@
"@types/supertest": "^2.0.15",
"@typescript-eslint/eslint-plugin": "5.37.0",
"@typescript-eslint/parser": "5.37.0",
"axios": "1.6.7",
"axios": "1.7.4",
"cross-env": "7.0.3",
"eslint": "8.23.1",
"fast-png": "^6.2.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/download_chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (platform === 'darwin') {

const outputPath = path.resolve(process.cwd(), 'dist', process.argv[3] || `plugin-${archArg}`);

const browserVersion = Browser.CHROME;
const browserVersion = Browser.CHROMEHEADLESSSHELL;

async function download() {
const buildId = await resolveBuildId(browserVersion, platform, 'latest');
Expand Down
2 changes: 1 addition & 1 deletion scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
yarn install --frozen-lockfile

# Start Grafana
docker-compose -f ./devenv/docker/test/docker-compose.yaml up -d
docker compose -f ./devenv/docker/test/docker-compose.yaml up -d

# Start testing
yarn jest
5 changes: 1 addition & 4 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ async function main() {
const env = Object.assign({}, process.env);
const command = argv._[0];

// See https://github.com/grafana/grafana-image-renderer/issues/460
process.env["PUPPETEER_DISABLE_HEADLESS_WARNING"] = "true"

if (command === undefined) {
const logger = new PluginLogger();
const config: PluginConfig = defaultPluginConfig;
Expand All @@ -30,7 +27,7 @@ async function main() {

config.rendering.chromeBin = computeExecutablePath({
cacheDir: path.dirname(process.execPath),
browser: Browser.CHROME,
browser: Browser.CHROMEHEADLESSSHELL,
buildId: chromeInfo.buildId,
});
logger.debug(`Setting chromeBin to ${config.rendering.chromeBin}`);
Expand Down
2 changes: 1 addition & 1 deletion src/browser/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class Browser {
launcherOptions.executablePath = this.config.chromeBin;
}

launcherOptions.headless = !this.config.headed;
launcherOptions.headless = !this.config.headed ? 'shell' : false;

return launcherOptions;
}
Expand Down
4 changes: 2 additions & 2 deletions src/browser/reusable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class ReusableBrowser extends Browser {
try {
page = await this.withTimingMetrics<puppeteer.Page>(async () => {
this.validateImageOptions(options);
context = await this.browser.createIncognitoBrowserContext();
context = await this.browser.createBrowserContext();
return context.newPage();
}, 'newPage');

Expand Down Expand Up @@ -52,7 +52,7 @@ export class ReusableBrowser extends Browser {

try {
this.validateRenderOptions(options);
context = await this.browser.createIncognitoBrowserContext();
context = await this.browser.createBrowserContext();
page = await context.newPage();

if (options.timezone) {
Expand Down
2 changes: 0 additions & 2 deletions src/service/http-server.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ let envSettings = {
}

beforeAll(() => {
process.env['PUPPETEER_DISABLE_HEADLESS_WARNING'] = 'true';

if (process.env['CI'] === 'true') {
domain = 'grafana';
}
Expand Down
Binary file modified tests/testdata/error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testdata/full-page-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testdata/graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testdata/table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 27928cf

Please sign in to comment.