Navalia Documentation logo

The Navalia module is a high-level manager that is used to balance and queue jobs against a browser (currently only Chrome is supported). Similar to web frameworks, the Navalia module doesn’t exit after all jobs are executed, but will hold onto the process until it’s terminated manually (CTRL+C). This allows for jobs to be ran against it asyncronously.

This document details the parameters you can use in constructing this module, which accepts a single argument: an object detailing the configuration.

You can view logs when the ‘DEBUG’ environment variable contains ‘navalia’ DEBUG=navalia node my-script.js

numInstances

An optional parameter which is used to launch a number of instances for Navalia to manage. Defaults to 1. Navalia keeps these browsers open regardless of load due to high-latency when starting them.

JavaScript

const { Navalia } = require('navalia');

const navalia = new Navalia({
  numInstances: 2,
});

TypeScript

import { Navalia } from 'navalia';

const navalia:Navalia = new Navalia({
  numInstances: 2,
});

maxJobs

The maximum number of jobs that a browser can execute before being rebooted. This parameter defaults to -1, or no maximum.

JavaScript

const { Navalia } = require('navalia');

const navalia = new Navalia({
  maxJobs: 50,
});

TypeScript

import { Navalia } from 'navalia';

const navalia:Navalia = new Navalia({
  maxJobs: 50,
});

workerTTL

The time-to-live in milliseconds that a browser can operate before being rebooted. This parameter defaults to -1, or no TTL.

JavaScript

const { Navalia } = require('navalia');

const navalia = new Navalia({
  workerTTL: 1000 * 60 * 60 * 2, // 2 hours
});

TypeScript

import { Navalia } from 'navalia';

const navalia:Navalia = new Navalia({
  workerTTL: 1000 * 60 * 60 * 2, // 2 hours
});

chromeOptions

The options to pass into each Chrome instance when started. The available options are:

JavaScript

const { Navalia } = require('navalia');

const navalia = new Navalia({
  chromeOptions: {
    maxActiveTabs: 10,
    timeout: 5000,
    flags: {
      disableSync: true,
    },
  },
});

TypeScript

import { Navalia, chromeOptions } from 'navalia';

const navalia:Navalia = new Navalia({
  chromeOptions: {
    maxActiveTabs: 10,
    timeout: 5000,
    flags: {
      disableSync: true,
    },
  },
});