I'm seeing this log: ``` jobID: "AJ_NWr6vXRZGX...
# ask-ai
g
I'm seeing this log:
Copy code
jobID: "AJ_NWr6vXRZGXbp"
    error: {
      "type": "TypeError",
      "message": "resampler.close is not a function",
      "stack":
          TypeError: resampler.close is not a function
              at forwardAudio (/Users/carloslostao/Eighteen/realtie/node_modules/.pnpm/@livekit+agents@1.2.8_@livekit+rtc-node@0.13.24_typescript@5.9.3_zod@4.3.6/node_modules/@livekit/agents/src/voice/generation.ts:864:16)
              at async run (/Users/carloslostao/Eighteen/realtie/node_modules/.pnpm/@livekit+agents@1.2.8_@livekit+rtc-node@0.13.24_typescript@5.9.3_zod@4.3.6/node_modules/@livekit/agents/src/utils.ts:507:14)
    }
while the agent speaks the sound is broken
t
Thanks for reaching out, carlos. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m sorry you’re seeing that error and the audio is broken. I’m responding about the
resampler.close is not a function
TypeError that appears while the agent speaks. I need a few details to diagnose this quickly: • Which versions are you using for
@livekit/agents
and
@livekit/rtc-node
(or your package-lock / pnpm-lock entry)? • Are you running this in Node.js or in a browser-like environment (e.g., Electron)? If Node, what Node version? • Does this happen every time the agent speaks or intermittently? Can you share a short repro (minimal code snippet) that triggers the error, or the sequence you call the voice agent in? • Do you have any custom resampler or audio-processing code plugged into the pipeline, or are you using the agents package without modifications? Quick suggestions while I wait for details: • Ensure package versions are compatible (matching major/minor of
@livekit/agents
and
@livekit/rtc-node
) and reinstall node_modules to rule out mixed versions. • If you’re running in an environment that lacks WebAudio or the browser AudioWorklet APIs, the resampler used by the agents may differ — confirm environment and Node version. • If you modified or replaced the resampler object, make sure it implements a
close()
method; the error means the code expects
resampler.close
to be a function but found something else. Send the version info and environment details and I’ll give targeted steps and, if needed, a minimal patch/workaround. , with interactive elements
g
Copy code
(base) carloslostao@MacBook-Pro-3 livekit % pnpm ls @livekit/agents 
Legend: production dependency, optional only, dev only

@realtie/livekit@1.0.0 /Users/carloslostao/Eighteen/realtie/livekit (PRIVATE)

dependencies:
@livekit/agents 1.2.8
Copy code
(base) carloslostao@MacBook-Pro-3 livekit % pnpm ls @livekit/rtc-node
Legend: production dependency, optional only, dev only

@realtie/livekit@1.0.0 /Users/carloslostao/Eighteen/realtie/livekit (PRIVATE)

dependencies:
@livekit/rtc-node 0.13.24
t
Thanks — I see you’re on
@livekit/agents@1.2.8
and
@livekit/rtc-node@0.13.24
. That helps. A few quick follow-ups so I can pinpoint the cause and give a fix or workaround: • Are you running this in plain Node.js, Electron, or a browser environment? If Node, what is your Node version (
node -v
)? • Does the error happen every time the agent speaks or only sometimes? • Do you have any custom audio/resampling code or shims (third-party resampler, WebAudio polyfills, etc.) in your app, or are you using the agents package unmodified? • Can you share the minimal call sequence that triggers the error (the snippet that starts the agent speaking) or confirm if this happens with the agents example code? While you gather that, try this quick check: • Remove node_modules and lockfile, reinstall (pnpm install) to ensure no mixed installs. • If you’re in Node and using any WebAudio polyfill, temporarily disable it to see if the error disappears. Send the Node/environment info and a small repro or call sequence and I’ll provide targeted steps or a patch. , with interactive elements
g
(base) carloslostao@MacBook-Pro-3 livekit % node -v v22.22.0
t
Thanks — I see you’re running Node v22.22.0. A couple last details to nail this down: • Are you running in plain Node (no Electron) with no WebAudio polyfills/shims? • Does the error occur every time the agent speaks or only sometimes? • Do you have any custom audio/resampling code or third-party resampler packages loaded? • Can you paste a minimal snippet that starts the agent speaking (or confirm if this happens with the agents example code)? If you prefer, paste the snippet and I’ll inspect it for the likely mismatch causing
resampler.close
to be undefined and provide a specific fix or workaround. , with interactive elements
g
pure nodejs
t
Thanks — I’m responding about the
resampler.close is not a function
TypeError you reported while the agent speaks. What’s happening: the Node resampler implementation your agents code expects includes a
close()
method; when that method is missing the pipeline throws and audio becomes corrupted. This is a known issue that was fixed by adding proper resampler resource management in recent releases. What to do next (recommended): 1. Update the packages to the latest compatible versions: ◦ Run:
pnpm up @livekit/agents @livekit/rtc-node
1. Reinstall to ensure no mixed artifacts: ◦ Remove lockfile and node_modules, then run
pnpm install
. 1. Verify after upgrade: ◦ Run your use case and confirm the TypeError is gone and audio is restored. If updating is not possible right now, tell me and I’ll provide a short workaround you can apply locally (patch or guard) and the exact minimal repro or call sequence I should inspect if the update doesn’t fix it. Sources: packages/livekit-rtc/src/audio_resampler.ts | Pipeline nodes and hooks | LiveKit Documentation | plugins/test/src/stt.ts, with interactive elements