Skip to content

Commit 22802e2

Browse files
committed
chore: refine review-comment fixes
- Default disableBrowserSandbox to false; only containerized and logLevel remain optional (their undefined value carries runtime semantics). - Inline the serviceLocator mention into the existing getGlobalConfig paragraph instead of appending a separate one.
1 parent 3a342cc commit 22802e2

3 files changed

Lines changed: 5 additions & 10 deletions

File tree

docs/guides/configuration.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ The last option to adjust Crawlee configuration is to use the <ApiLink to="core/
137137

138138
### Global Configuration
139139

140-
By default, there is a global singleton instance of `Configuration` class, it is used by the crawlers and some other classes that depend on a configurable behavior. In most cases you don't need to adjust any options there, but if needed - you can get access to it via <ApiLink to="core/class/Configuration#getGlobalConfig">`Configuration.getGlobalConfig()`</ApiLink> function. Configuration values are accessible directly as properties.
141-
142-
Under the hood, `Configuration.getGlobalConfig()` delegates to <ApiLink to="core/class/ServiceLocator">`serviceLocator`</ApiLink>, which is the single source of truth for Crawlee's shared services (configuration, event manager, storage client, logger). You can access the same instance via `serviceLocator.getConfiguration()` and swap services globally with `serviceLocator.setConfiguration(...)` before any crawler is created.
140+
By default, there is a global singleton instance of `Configuration` class, it is used by the crawlers and some other classes that depend on a configurable behavior. In most cases you don't need to adjust any options there, but if needed - you can access it via <ApiLink to="core/class/Configuration#getGlobalConfig">`Configuration.getGlobalConfig()`</ApiLink>, which delegates to the global <ApiLink to="core/class/ServiceLocator">`serviceLocator`</ApiLink> — the single source of truth for Crawlee's shared services (configuration, event manager, storage client, logger). You can also reach the same instance directly via `serviceLocator.getConfiguration()` or swap services globally with `serviceLocator.setConfiguration(...)` before any crawler is created. Configuration values are accessible directly as properties on the instance.
143141

144142
```js
145143
import { CheerioCrawler, Configuration, sleep } from 'crawlee';

packages/core/src/configuration.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ export const crawleeConfigFields = {
7676
xvfb: field(coerceBoolean.default(false), 'CRAWLEE_XVFB'),
7777
chromeExecutablePath: field(z.string().optional(), 'CRAWLEE_CHROME_EXECUTABLE_PATH'),
7878
defaultBrowserPath: field(z.string().optional(), 'CRAWLEE_DEFAULT_BROWSER_PATH'),
79-
disableBrowserSandbox: field(coerceBoolean.optional(), 'CRAWLEE_DISABLE_BROWSER_SANDBOX'),
79+
/** @default false */
80+
disableBrowserSandbox: field(coerceBoolean.default(false), 'CRAWLEE_DISABLE_BROWSER_SANDBOX'),
8081
logLevel: field(logLevelSchema.optional(), 'CRAWLEE_LOG_LEVEL'),
8182
/** @default true */
8283
persistStorage: field(coerceBoolean.default(true), 'CRAWLEE_PERSIST_STORAGE'),

packages/core/test/core/configuration.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ describe('Configuration', () => {
4141
expect(config.inputKey).toBe('INPUT');
4242
expect(config.headless).toBe(true);
4343
expect(config.xvfb).toBe(false);
44+
expect(config.disableBrowserSandbox).toBe(false);
4445
expect(config.purgeOnStart).toBe(true);
4546
expect(config.persistStorage).toBe(true);
4647
expect(config.maxUsedCpuRatio).toBe(0.95);
@@ -49,11 +50,7 @@ describe('Configuration', () => {
4950
expect(config.systemInfoIntervalMillis).toBe(1_000);
5051
});
5152

52-
// `disableBrowserSandbox`, `containerized`, and `logLevel` are intentionally optional
53-
// (no default) — `undefined` is a meaningful signal for each:
54-
// - `disableBrowserSandbox`: only a boolean check is done at the call site, so `undefined`
55-
// behaves the same as `false` and leaves room to distinguish "unset" from "explicitly false"
56-
// if callers ever need to.
53+
// `containerized` and `logLevel` are intentionally optional — `undefined` is a meaningful signal:
5754
// - `containerized`: consumers fall back to runtime detection via `isContainerized()` using
5855
// `config.containerized ?? (await isContainerized())`; defaulting to `false` would disable
5956
// auto-detection.
@@ -64,7 +61,6 @@ describe('Configuration', () => {
6461
expect(config.memoryMbytes).toBeUndefined();
6562
expect(config.chromeExecutablePath).toBeUndefined();
6663
expect(config.defaultBrowserPath).toBeUndefined();
67-
expect(config.disableBrowserSandbox).toBeUndefined();
6864
expect(config.containerized).toBeUndefined();
6965
expect(config.logLevel).toBeUndefined();
7066
});

0 commit comments

Comments
 (0)