Skip to content
Closed
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
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# PUPPETEER CONFIG
PUPPETEER_PIPE = false
PUPPETEER_TEMP_DIR = ./tmp/
PUPPETEER_LAUNCH_RETRY_WINDOW = 30000

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ The format, along with its default values, is as follows (using the recommended
{
"puppeteer": {
"args": [],
"pipe": false,
"launchRetryWindow": 30000,
"tempDir": "./tmp/"
},
Expand Down Expand Up @@ -358,6 +359,7 @@ These variables are set in your environment and take precedence over options fro

### Puppeteer Config

- `PUPPETEER_PIPE`: Use a pipe instead of a WebSocket for the browser connection (defaults to `false`). This disables the browser's WebSocket debugging endpoint. When `DEBUG_ENABLE` is `true`, set `DEBUG_DEBUGGING_PORT` to `0` to avoid combining pipe transport with a nonzero debugging port.
- `PUPPETEER_TEMP_DIR`: The directory for Puppeteer to store temporary files (defaults to `./tmp/`).
- `PUPPETEER_LAUNCH_RETRY_WINDOW`: The duration, in milliseconds, to keep retrying a browser launch before reporting it as failed (defaults to `30000`).

Expand Down
4 changes: 2 additions & 2 deletions dist/index.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.esm.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ async function launchBrowser(puppeteerArgs) {

const launchOptions = {
headless: other.browserShellMode ? 'shell' : true,
pipe: puppeteerOptions.pipe,
userDataDir: puppeteerOptions.tempDir || './tmp/',
args: puppeteerArgs,
handleSIGINT: false,
Expand Down
1 change: 1 addition & 0 deletions lib/envs.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const v = {

export const Config = z.object({
// puppeteer
PUPPETEER_PIPE: v.boolean(),
PUPPETEER_TEMP_DIR: v.path(),
PUPPETEER_LAUNCH_RETRY_WINDOW: v.nonNegativeNum(),

Expand Down
13 changes: 13 additions & 0 deletions lib/schemas/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ export const defaultConfig = {
type: 'string[]',
description: 'Arguments array to send to Puppeteer.'
},
pipe: {
value: false,
type: 'boolean',
envLink: 'PUPPETEER_PIPE',
description:
'Use a pipe instead of a WebSocket for the browser connection.'
},
launchRetryWindow: {
value: 30000,
type: 'number',
Expand Down Expand Up @@ -772,6 +779,12 @@ export const promptsConfig = {
message: 'Puppeteer arguments',
initial: defaultConfig.puppeteer.args.value.join(','),
separator: ','
},
{
type: 'toggle',
name: 'pipe',
message: 'Use a pipe for the browser connection',
initial: defaultConfig.puppeteer.pipe.value
}
],
highcharts: [
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/envs.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
import { Config } from '../../lib/envs';

describe('Environment variables should be correctly parsed', () => {
test('PUPPETEER_PIPE should be a boolean', () => {
expect(
Config.partial().parse({ PUPPETEER_PIPE: 'true' }).PUPPETEER_PIPE
).toEqual(true);
expect(
Config.partial().parse({ PUPPETEER_PIPE: 'false' }).PUPPETEER_PIPE
).toEqual(false);
expect(
Config.partial().parse({ PUPPETEER_PIPE: '' }).PUPPETEER_PIPE
).toBeUndefined();
expect(() =>
Config.partial().parse({ PUPPETEER_PIPE: 'invalid' })
).toThrow();
});

test('PUPPETEER_TEMP_DIR should be a valid path', () => {
const env = { PUPPETEER_TEMP_DIR: '/path/to/dir' };
expect(Config.partial().parse(env).PUPPETEER_TEMP_DIR).toEqual(
Expand Down