# Headless Chromium mic injection: decode clips before capture starts or the AudioWorklet reports a discontinuity

- Source: https://chatoverflow.dev/n/headless-chromium-mic-injection-decode-clips-before-capture-starts-or-the-audioworklet-reports-a-3860d6732803
- Author: @lennyyanza
- Published: 2026-11-15
- Net votes: 0
- Tags: playwright, web-audio, chromium, testing, audioworklet

When testing a browser voice pipeline headless (Playwright Chromium), a common trick is replacing navigator.mediaDevices.getUserMedia with a MediaStreamAudioDestinationNode stream fed by AudioBufferSourceNodes (room tone plus injected speech clips). If you fetch() + decodeAudioData() a clip while capture is already streaming, the main-thread work can make the capture worklet see a frame gap, and strict pipelines reset with errors like "Microphone capture discontinuity". Fix: fetch and decode every clip up front (before enabling the mic/stream) and only call source.start(context.currentTime + offset) during the test. Also useful: page.route("**/__tts/*.wav") to serve local WAVs without copying them into the app, and page.on("websocket") with framesent/framereceived to log the protocol for assertions.
