RuntimeConfig
Configuration for JavaScript runtime instances.
Use this to configure heap limits, execution timeouts, and bootstrap scripts before creating a Runtime.
__init__
__init__(max_heap_size: int | None = None, initial_heap_size: int | None = None, bootstrap: str | None = None, timeout: float | int | None = None, enable_console: bool | None = False, on_console: Callable[[str, list[Any]], Any] | None = None, inspector: InspectorConfig | None = None, snapshot: bytes | None = None, max_serialization_depth: int | None = None, max_serialization_bytes: int | None = None, force_kill_grace: float | int | timedelta | None = None, max_buffer_bytes: int | None = None) -> None
Create a new runtime configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_heap_size
|
int | None
|
Maximum JS heap size in bytes. Does not bound
|
None
|
initial_heap_size
|
int | None
|
Initial heap size in bytes |
None
|
bootstrap
|
str | None
|
JavaScript source code to execute on startup |
None
|
timeout
|
float | int | None
|
Execution timeout in seconds (float or int). A fired
deadline terminates whatever the isolate is running at that
moment, which is not necessarily the job that timed out: the
isolate is single-threaded and |
None
|
enable_console
|
bool | None
|
Whether |
False
|
on_console
|
Callable[[str, list[Any]], Any] | None
|
Optional callable invoked as |
None
|
inspector
|
InspectorConfig | None
|
Optional inspector configuration enabling Chrome DevTools |
None
|
snapshot
|
bytes | None
|
Optional V8 startup snapshot bytes |
None
|
max_serialization_depth
|
int | None
|
Maximum nesting depth when transferring values
(default 100). Raising it past roughly 900 is unsafe if you then
pass a deep argument from a small-stack thread: the Python-to-JS
conversion recurses on the calling thread, and a
|
None
|
max_serialization_bytes
|
int | None
|
Maximum serialized byte size when transferring values |
None
|
force_kill_grace
|
float | int | timedelta | None
|
How long a blocked caller waits for the runtime to
acknowledge a termination before abandoning the runtime thread and
raising |
None
|
on_console
property
writable
The configured console callback, if any.
max_buffer_bytes
property
writable
Cap on live ArrayBuffer / SharedArrayBuffer bytes (None = uncapped).
enable_console
property
Whether console APIs are enabled inside the runtime.
inspector
property
writable
inspector: InspectorConfig | None
Inspector configuration if debugging is enabled.
max_serialization_depth
property
writable
Maximum recursion depth allowed when serializing values.
max_serialization_bytes
property
writable
Maximum byte size allowed when serializing values.