Skip to main content
Version: 4.4.2

setReusableSandboxOptions

The setReusableSandboxOptions() function configures the reuse of the same underlying sandbox for multiple requests, which can improve performance by avoiding the overhead of initializing a new sandbox for each request.

Note: Can only be used during build-time initialization, not when processing requests.

Request failures, such as invalid request URLs, uncaught JavaScript exceptions, or response delivery errors, are logged and retire the sandbox without a nonzero process exit. The runtime sends a 500 response if no response has started and it is still possible to send one. These sandboxes are not reused, regardless of the configured limits. Fatal runtime failures can still cause a nonzero exit or trap.

Syntax​

setReusableSandboxOptions(options)

Parameters​

  • options : Object
    • The configuration options for the reusable sandbox.
      • maxRequests : number (default: 1, 0 means unlimited)
        • The maximum number of requests that can be handled by a single sandbox before it is recycled.
      • betweenRequestTimeoutMs : number (default: not specified)
        • The amount of time in milliseconds to wait between requests before recycling the sandbox.
      • maxMemoryMiB : number (default: no limit)
        • The maximum amount of memory in MiB that the sandbox can use before it is recycled.
      • sandboxTimeoutMs : number (default: no timeout)
        • The maximum amount of time in milliseconds that a sandbox can be active before it is recycled.