Troubleshooting · October 2026
Session replay missing from WhaTap browser monitoring? Check worker-src in your CSP
A Content Security Policy with no worker-src falls back to script-src, which blocks the WhaTap browser agent's blob: Web Workers. Page-load beacons keep returning 200 while session replay silently never sends. One directive fixes it, verified end to end in a lab.
TL;DR
WhaTap browser monitoring looks like it is working — pageLoad and resource beacons return 200 — but session replay is never collected. The browser console shows:
Creating a worker from 'blob:https://app.example.com/4798...' violates the following
Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'unsafe-eval' https:".
Note that 'worker-src' was not explicitly set, so 'script-src' is used as a fallback.
The action has been blocked. @ whatap-browser-agent.js:10The fix is one directive in the site’s CSP:
worker-src 'self' blob:;That is the whole change. worker-src governs only Worker/SharedWorker/ServiceWorker sources, so it does not loosen script-src for ordinary scripts.
Symptom
On the instrumented page, the agent’s console looks like this (browser agent v1.3.15):
- One console error — the worker creation above, attributed to
whatap-browser-agent.js. pageLoad,resource,collectandv2/webVitalsbeacons are sent and return 200.- No
sessionreplaybeacon is sent at all, ever. In the network panel you will not see the request fail — it is simply never made. - In the WhaTap console, the session-replay surface is empty for that project while the other browser metrics look healthy.
If you only check “are beacons arriving”, you will conclude monitoring is fine. It is half instrumented, and the half that is missing is the one that records the user’s session.
Why it looks like a configuration error somewhere else
The tell that it is not a collector problem: a wrong collection endpoint, a wrong port, or a firewall block makes beacons fail with an HTTP error you can see. Here the beacons that are sent succeed. The failure happened inside the browser, before any network request was made.
The second reason it misleads: the CSP in the client’s config is not obviously wrong. It is a perfectly normal, fairly strict policy. Nothing in it says “no workers” — the problem is the absence of a directive, and CSP absence behaves as an implicit fallback rather than an error.
Reproduction
You do not need WhaTap to see the browser behaviour — a page with any blob worker under such a CSP reproduces the console error. To prove it is specifically the replay worker that dies, instrument a page with the real agent snippet.
1. A site whose CSP has no worker-src (a snippet included into your server block):
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https:; style-src 'self' 'unsafe-inline' https:; img-src 'self' data: https:; font-src 'self' data: https:; connect-src 'self' https: wss:; frame-src 'self' https:; frame-ancestors 'self'; object-src 'none'; base-uri 'self'; form-action 'self'" always;2. A page instrumented with the WhaTap snippet, including a proxyBaseUrl so beacons go through your own host to the collector:
<script>
// WhaTap browser agent snippet: pcode + access key, agent URL, collection endpoint
// proxyBaseUrl: location.origin + "/api/v1/system-sync/"
</script>3. A script that drives the page and reports what actually left the browser. A short Playwright script is enough: load the page, type into the fields, click, wait ~15 s, navigate away to flush, reload — then print the CSP header, any securitypolicyviolation events, the console errors, and every beacon sent to the sync path:
cd lab/test && npm i && node test.mjs before # URL env var overrides the targetThen flip the CSP to include worker-src 'self' blob:, reload, and run it again. The result is unambiguous:
Before (no worker-src) | After (worker-src 'self' blob:) | |
|---|---|---|
| CSP violation | worker-src blocked blob | none |
pageLoad / resource / v2/webVitals | 200 | 200 |
sessionreplay | never sent | 200 |
End-to-end confirmation is the WhaTap console: User action analysis → Session replay plays back a recorded session with the typed text and the click timeline visible. In our lab only the post-fix sessions carried replay data — the pre-fix sessions were listed but had nothing to play.
Confirmed on a live client site. The directive was rolled out to the client’s production nginx and session replay started recording — the lab reproduction and the real site agreed. No other policy change was needed.
Root cause
The browser agent builds two Web Workers from blob: URLs:
| Worker | Purpose | When blocked |
|---|---|---|
Deflate worker (new Worker(URL.createObjectURL(new Blob(...)))) | Compresses outgoing beacons | Catches the error and compresses on the main thread. Everything else keeps working — which is exactly why pageLoad/resource still return 200. |
| Session-replay worker (rrweb) | Records and compresses the replay stream | Tries a blob: worker, then falls back to a data:text/javascript;base64 worker. A CSP that permits neither means replay never sends. |
A CSP with no worker-src does not mean “workers are unrestricted” — it means the browser applies the fallback chain and script-src is consulted instead. A typical script-src allows 'self' and your CDNs but not blob:, so every blob worker is refused at creation time.
The failure is therefore silent and partial: one worker degrades to a fallback path, the other has no viable fallback, and nothing surfaces except a console error that is easy to skim past.
The fix
Add worker-src 'self' blob: to the policy, next to connect-src:
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https:; style-src 'self' 'unsafe-inline' https:; img-src 'self' data: https:; font-src 'self' data: https:; connect-src 'self' https: wss:; worker-src 'self' blob:; frame-src 'self' https:; frame-ancestors 'self'; object-src 'none'; base-uri 'self'; form-action 'self'" always;Procedure, with a rollback path:
cp /etc/nginx/snippets/<headers>.conf /etc/nginx/snippets/<headers>.conf.bak.worker.$(date +%Y%m%d-%H%M%S)
# edit the CSP line as above
nginx -t && systemctl reload nginx
curl -sI https://<site>/ | grep -i content-security # must now contain: worker-src 'self' blob:Then hard-reload with the cache disabled (Ctrl+Shift+R, or DevTools → “Disable cache”). The worker error disappears from the console and a …/sessionreplay POST appears in the network panel.
Rollback: restore the .bak.worker.* file, then nginx -t && systemctl reload nginx.
Finding the CSP in the first place
curl -sI https://<site> | grep -i content-security
grep -rn Content-Security-Policy /etc/nginx/It is not always nginx: Apache and IIS headers, an application framework, or a <meta http-equiv="Content-Security-Policy"> in index.html can all be the source. Fix it at the source, not with a second header that fights the first.
Caveats and scope
- Do not add
data:toworker-src. It is only the replay worker’s internal fallback andblob:alone is verified to be enough.'self' blob:is the narrow change. - Check every place the CSP is set. A page can receive one policy from a header and another from a meta tag; the browser enforces all of them, and the strictest one binds. If the headers are emitted by a snippet included in several server blocks, one edit covers them all — but a
locationblock with its ownadd_headerdoes not inherit the server-level headers in nginx, so the snippet has to be included there as well. - This is the replay-specific failure mode. A CSP can also break browser monitoring more visibly: if
script-srcdoes not allow the agent URL, nothing loads at all, and ifconnect-srcdoes not allow the collection URL, beacons die at the network layer. Both are louder symptoms than this one. - Session replay records what the page shows. Masking options in the snippet decide how much: with input masking off, typed values are recorded (password fields are masked regardless). For a login or customer portal that is usually not what you want — consider
sessionReplayMaskAllInputs: trueunless the values are genuinely needed. worker-srchas no effect on whether replay is enabled at all. If replay is switched off in the snippet, this fix changes nothing; and a project with replay disabled will never sendsessionreplay.
Takeaways
- A CSP is not just an allow-list, it is a fallback chain. A missing directive quietly means “inherit from a broader one”, and
worker-srcfalls back toscript-src— which almost never allowsblob:. - Partial success is the hardest symptom to read. An agent that degrades gracefully (main-thread compression) and an agent that dies silently (blocked replay worker) look the same in a beacon count. Verify the specific beacon you care about, not the traffic level.
- Read the console, not just the network panel. This bug produces exactly one console error and zero failed requests. Anything that inspects only HTTP status codes will report the site healthy.
worker-src 'self' blob:is a small, targeted change — worth making on any site that runs WhaTap browser monitoring before the first “replay isn’t showing up” ticket arrives.
Derived from internal field work; client and environment details have been generalised. Exact error strings, configuration keys and commands are as observed on the affected site.