NinjaSurfer Docs / Troubleshooting ← Back to the site
Docs · Troubleshooting

Troubleshooting

Common issues and how to resolve them. The SDK launches browsers through Playwright, so most other problems are ordinary Playwright problems and its docs apply. On Linux, browsers are driven through the SDK, CLI or MCP; the Linux sections below are for servers and containers.

ENV_MISSING: "HOME is not set" / "LOCALAPPDATA is not set"

NinjaSurfer keeps its files only in the folders the system names, and never guesses one. The variable in the message is not set for this process: HOME on macOS and Linux, LOCALAPPDATA or APPDATA on Windows (USERPROFILE for the home folder). This happens with a systemd system service without User=, a cron job or a container that starts with an empty environment, or a Windows task started without a user profile. Nothing was written.

Set the variable for that process (for systemd: User= plus Environment=HOME=/home/you, or Environment=HOME=... on its own), or name each folder yourself:

bash
export NINJASURFER_CACHE_DIR=/srv/ninjasurfer/cache        # engines, fonts
export NINJASURFER_PROFILES_DIR=/srv/ninjasurfer/profiles  # profiles
export NINJASURFER_FONT_PACKS_DIR=/srv/ninjasurfer/fonts   # the font-pack store

The message names the NINJASURFER_* variable for that folder when there is one. An XDG_* variable is used only when it is an absolute path.

The first launch is slow or seems to hang

A machine's first start of a persona downloads what that persona needs, once; later starts reuse it. Most of the wait is fonts, and macOS needs the most:

Download Approximate size Holds the start?
Browser build about 250 MB on Linux; an iPhone (WebKit) profile adds about 200 MB yes
The persona's fonts Windows about 0.4 GB (Office fonts add about 20 MB); macOS about 1.7 GB (system 1.2 GB + Office 0.5 GB); iPhone about 0.7 GB; Android 0.07–0.15 GB per version yes

The sizes change as packs are updated. At 10 Mbit/s a first macOS start downloads for about 25 minutes, and at 1 Mbit/s for hours. Progress is reported while it runs (startProfile's onProgress, the CLI's progress lines, the app's download window), so a long first start is not a hang.

Everything is cached under ~/.cache/ninjasurfer/ (macOS: ~/Library/Caches/ninjasurfer/, Windows: %LOCALAPPDATA%\ninjasurfer\); NINJASURFER_CACHE_DIR moves it. Pre-fetch so the cost isn't hidden inside your first script run:

bash
ninjasurfer fetch                                  # standalone CLI (on PATH)
node node_modules/ninjasurfer/dist/cli.js fetch    # npm SDK

fetch brings the browser build; ninjasurfer fonts fetch-operator brings the operator fonts. On servers and images, seed the fonts once into a shared store instead: see Installation: servers and images.

Print where the browser landed, or wipe the cache to force a clean re-download:

bash
ninjasurfer path     # show the cached binary path
ninjasurfer clear    # remove the whole cache directory: browser builds and fonts download again

The download fails or the archive won't verify

Every file is checked by SHA-256 against the signed catalogs and refused on a mismatch, so a verification error usually means a truncated or proxied download rather than a bad build. Retry on a clean network. Behind a corporate proxy or firewall, allow the download hosts (cdn.cf.surfer.ninja, cdn.bn.surfer.ninja, cdn.sl.surfer.ninja and s3.surfer.ninja; see where downloads come from) and api.surfer.ninja (your account). To pin and cache a specific build out of band, set NINJASURFER_VERSION and run ninjasurfer fetch once.

PROFILE_FONTS: "its signed set's document is not on this computer and could not be read"

The signed fonts index lists each font set's files in a small signed document of its own. A start checks the profile's installed font packs against those documents, and every document this computer has read is kept in the cache (<cache>/operator-fonts/set-docs/; Clear cache keeps them). This error means a pack is installed here but its document has never been read on this computer, and the start could not read it now: the computer is offline, or the start is one that never downloads (the SDK's NinjaSurfer() Playwright launcher checks the fonts and leaves every download to prepareStart). The start is refused rather than run with fonts it could not check.

Read it once while online: start the profile (the app, the CLI start, startProfile), or call prepareStart / prepareRuntime before a NinjaSurfer() launch. Every later start, online or offline, uses the kept document. For a pre-seeded image or an offline server, do that once per persona while building it, or copy <cache>/operator-fonts/set-docs/ from a machine that has: each document is checked against its signed size and SHA-256 when it is read.

Linux: "running as root without --no-sandbox" or a sandbox crash

The SDK launches with the Chromium sandbox enabled on every platform (chromium_sandbox=True / chromiumSandbox: true); it never adds --no-sandbox or --no-zygote on its own. Chromium refuses to start as root with the sandbox on, so run the automation as an unprivileged user — in containers, add a non-root USER. On minimal images a sandbox crash usually means missing shared libraries or a kernel/user-namespace restriction; install the Playwright system dependencies once:

bash
npx playwright install-deps chromium
# or, Ubuntu 24.04 and later, by hand (the libraries the browser build loads):
sudo apt-get install -y libnss3 libnspr4 libatk1.0-0t64 libatk-bridge2.0-0t64 libatspi2.0-0t64 \
  libcups2t64 libdbus-1-3 libgbm1 libglib2.0-0t64 libpango-1.0-0 libcairo2 libx11-6 libxcb1 \
  libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 libasound2t64
# Ubuntu 22.04 / Debian 12: the same without the t64 suffix (libatk1.0-0, libasound2, ...)

Disabling the sandbox is an explicit choice you make, not an SDK default: pass chromiumSandbox: false. That removes a security boundary between web content and your host; only do it in a disposable environment you already trust.

You do not run playwright install — NinjaSurfer brings its own browser; install-deps only pulls the OS libraries.

Ubuntu 23.10+: "No usable sandbox"

Ubuntu 23.10 and later set kernel.apparmor_restrict_unprivileged_userns=1: unprivileged user namespaces are allowed only for programs whose AppArmor profile permits them. NinjaSurfer then has no usable Linux sandbox unless one of the following is true, and Chromium stops with "No usable sandbox!" (or "Failed to move to new namespace"). The SDK reports this as SandboxUnavailableError with the fix below; it never retries with --no-sandbox.

Never grant these privileges to a browser in a location your user can write to, such as the SDK cache under ~/.cache or ~/Library: a setuid bit or an AppArmor userns rule there extends to any binary later placed at that path. Install the browser system-wide in a root-owned directory instead and point the SDK at it:

bash
sudo env NINJASURFER_CACHE_DIR=/opt/ninjasurfer "$(command -v ninjasurfer)" fetch
# npm SDK: sudo env NINJASURFER_CACHE_DIR=/opt/ninjasurfer node node_modules/ninjasurfer/dist/cli.js fetch
export NINJASURFER_CACHE_DIR=/opt/ninjasurfer   # for every user/process that launches it

Then use one of:

The SDK error message names the concrete helper command only when the browser executable, its helper and every directory above them are root-owned and not writable by other users.

Re-enabling unprivileged user namespaces system-wide (sysctl kernel.apparmor_restrict_unprivileged_userns=0) also works but lowers protection for every program on the host; prefer the per-executable fixes.

Docker / Linux containers: "sandboxing failed" at startup

The Chromium sandbox in a container needs user, PID and network namespaces. Docker's default seccomp profile denies the namespace system calls (unshare/clone with CLONE_NEWUSER) to an unprivileged container, so the browser does not start there; the launcher refuses with a message that names what is missing. This is a deployment requirement, not something the SDK can work around.

Supported container configuration: the seccomp profile that ships with every Linux release, packaging/linux/docker/ninjasurfer-seccomp.json (docker/ninjasurfer-seccomp.json in the full Linux archive), with no added capabilities, as a non-root user:

bash
docker run --cap-drop ALL --security-opt no-new-privileges \
  --security-opt seccomp=ninjasurfer-seccomp.json \
  --user 65534:65534 IMAGE ...

The profile is Docker's default profile with three changes: clone and unshare may create user, PID and network namespaces (mount, cgroup, UTS and IPC namespaces stay forbidden), and chroot is allowed without CAP_SYS_CHROOT. Keep Docker's default AppArmor profile (docker-default); do not run with apparmor=unconfined. No setuid helper, no sysctl and no host AppArmor profile are needed. The release's packaging/linux/SANDBOX.md describes this configuration and the host-side options in full.

Never use --privileged or --no-sandbox. Turning the browser sandbox off is not a fix for this error; the SDK never does it for you (see the previous section for what an explicit opt-out means).

I can't see anything — how do I watch it run?

Library launches are headless by default. Pass headless: false to open a visible window while you debug a selector or a login flow:

javascript
import { NinjaSurfer } from "ninjasurfer";

const browser = await NinjaSurfer({ headless: false });
const page = await browser.newPage();
await page.goto("https://example.com");
await page.pause();   // opens the Playwright Inspector

page.pause() drops you into the Playwright Inspector so you can step through and pick selectors interactively. Headful mode needs a display; on a headless server run it under xvfb-run.

My timezone doesn't match my proxy

A clock that disagrees with the exit IP is an easy tell. Set timezone: "auto" and the SDK resolves the egress IP (through your proxy, if set) to an IANA zone and applies it:

javascript
const browser = await NinjaSurfer({ proxy: { server: "http://proxy.example.com:8000" }, timezone: "auto" });

If "auto" resolves to nothing, the egress probe couldn't reach the network or the IP isn't in the database; pass an explicit IANA name such as "Europe/Berlin" instead. lookupTimezone(ip) and resolveTimezone() from ninjasurfer show what an IP, or your own egress, resolves to without launching a browser.

WebRtcProxyError when I give a context a proxy

The browser was launched without a proxy, so the SDK gave it Chrome's stock WebRTC policy, and that policy applies to every context. The browser cannot see a proxy given only to a context: STUN would reach the network outside it and a WebRTC srflx candidate would carry your real IP address. The SDK refuses such a context or page instead of letting it leak. Either pass the proxy at launch (NinjaSurfer({ proxy: { server: "http://proxy.example.com:8000" } })), or keep one browser for many proxies and put WebRTC on proxied routes only:

javascript
const browser = await NinjaSurfer({ webrtc: "proxy-only" });
const ctx = await browser.newContext({ proxy: { server: "socks5://proxy.example.com:1080" } });

With proxy-only, WebRTC connects only through TURN over TCP/TLS through the proxy; pages that need direct UDP or STUN fail, as they would behind a strict firewall. webrtc: "stock" turns the check off and accepts the leak.

A CDP endpoint (ninjasurfer start PROFILE, startBrowser, profile open, agents, MCP) is on auto by default, so WebRTC works there without a proxy as in stock Chrome. Its client can give contexts proxies the SDK never sees, so the SDK cannot refuse them; the browser keeps such a context off direct UDP itself: a context created with its own proxy (Playwright newContext({ proxy }), Puppeteer createBrowserContext({ proxyServer })) gathers no srflx or host candidate and connects only through TURN over TCP/TLS via that proxy. Start it with --webrtc proxy-only to keep every context on proxied routes.

A site still reads me as canvas/WebGL software rendering

That's expected. Canvas, WebGL and WebGPU report and render on the real backend. When the browser has no working hardware GPU (the graphics="auto" fallback, on any OS) or with graphics="software", that backend is SwiftShader. Windows and macOS personas report the GPU of their reference capture (WebGL vendor/renderer, WebGPU adapter info) and WebGPU works, but the pixels and the performance are SwiftShader's, and the features the backend cannot run are not declared. There is no canvas bridge and no canvas noise. See what a persona changes.

I'm still getting blocked

A persona changes some browser identity fields, not your network identity, the host-derived surfaces or your behaviour, and NinjaSurfer makes no promise that a site will not block a session or show a CAPTCHA. Common reasons a site blocks:

See personas for how identity, network and behaviour fit together.

Verifying the persona looks right

Open a fingerprinting test page in the profile and check that the persona fields match its catalog entry, and that everything else matches the host (what a persona changes). A test page's verdict is an observation, not a guarantee for other sites. navigator.webdriver is always false (this differs from the WebDriver specification for automated sessions; see Playwright defaults).