Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Puppeteer: Upgrade to v22 #556

Merged
merged 9 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer needed. We are using the shell value instead of the new headless mode.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function was renamed on version 22

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