denoland/deno · error · TypeError
ERR_HTTP2_INVALID_SETTING_VALUE
ERR_HTTP2_INVALID_SETTING_VALUE
Error message
Invalid value for setting "enablePush": ${settings.enablePush} What it means
In validateSettings, settings.enablePush must be a boolean when provided; any other type (string 'false', number 1, null-ish handled separately) throws ERR_HTTP2_INVALID_SETTING_VALUE with the offending value embedded in the message. enablePush controls whether the client accepts server push, so a truthy-but-wrong type cannot be silently coerced.
Source
Thrown at ext/node/polyfills/http2.ts:1428
kMaxStreams,
);
assertWithinRange(
"maxHeaderListSize",
settings.maxHeaderListSize,
0,
kMaxInt,
);
assertWithinRange(
"maxHeaderSize",
settings.maxHeaderSize,
0,
kMaxInt,
);
if (
settings.enablePush !== undefined &&
typeof settings.enablePush !== "boolean"
) {
throw new ERR_HTTP2_INVALID_SETTING_VALUE.HideStackFramesError(
"enablePush",
settings.enablePush,
);
}
if (
settings.enableConnectProtocol !== undefined &&
typeof settings.enableConnectProtocol !== "boolean"
) {
throw new ERR_HTTP2_INVALID_SETTING_VALUE.HideStackFramesError(
"enableConnectProtocol",
settings.enableConnectProtocol,
);
}
});
// Allow selectively copying the entries that have explicitly been set to
// another typed array. In upstream Node this wraps the TypedArray in a Proxy
// to track index assignments. Deno's polyfill does not (yet) replace thisView on GitHub (pinned to 9ad36f7a2c)
Solutions
- Coerce env-derived values: enablePush: process.env.DISABLE_PUSH !== 'true'
- Validate the settings object with a boolean check before connect/updateSettings (see validationCode)
- Type the settings parameter (Partial<http2.Settings>) so TypeScript rejects non-booleans at compile time
Example fix
// before
http2.connect(url, { settings: { enablePush: process.env.PUSH } }); // string → throws
// after
http2.connect(url, {
settings: { enablePush: process.env.PUSH === 'true' }, // real boolean
}); Defensive patterns
Strategy: validation
Validate before calling
const bool = (v: unknown): boolean | undefined =>
v === undefined ? undefined : v === true || v === 'true';
http2.connect(url, { settings: { enablePush: bool(cfg.enablePush) } }); Type guard
const isBooleanOrUndefined = (v: unknown): v is boolean | undefined => v === undefined || typeof v === 'boolean';
Prevention
- Coerce env-var and CLI-derived values to real booleans at the boundary
- Type settings as Partial<http2.Settings> and let the compiler reject strings/numbers
- Freeze validated settings objects after config parsing
When it happens
Trigger: http2.connect(url, { settings: { enablePush: 'false' } }); settings sourced from process.env (always strings); updateSettings({ enablePush: 1 }); JSON config where the value was quoted.
Common situations: Feature flags wired through environment variables (DISABLE_PUSH='true') and passed without conversion; YAML/JSON configs that serialize booleans as strings; flags defaulting to numbers (0/1) from CLI parsers.
Related errors
- ERR_HTTP2_TOO_MANY_CUSTOM_SETTINGS
- ERR_HTTP2_PUSH_DISABLED
- ERR_INVALID_ARG_TYPE
- ERR_INVALID_URL
- ERR_HTTP2_NO_SOCKET_MANIPULATION
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/c3058957d7549a58.
Report an issue: GitHub.