Fixing JavaScript heap out of memory errors in Langfuse

Node.js heap crashes in Langfuse web and worker containers usually mean the heap ceiling and the container memory limit disagree. Aligning them lets the orchestrator handle memory pressure before the process dies.

On this page

Why Langfuse web and worker fail with JavaScript heap out of memory

When a self-hosted Langfuse web or worker container restarts with a JavaScript heap out of memory error, the usual cause is not that the host is out of memory. Langfuse runs on Node.js, and the V8 engine that executes it enforces its own heap ceiling for JavaScript objects. That ceiling is set separately from the memory limit the container runtime or Kubernetes applies to the whole container. If V8 is allowed to grow past the container limit, the kernel or orchestrator may kill the process first. If the heap ceiling is set far below the container limit, Node.js throws its own out-of-memory error while memory is still available. Both outcomes look like a crash loop in the logs, but they call for different fixes.

The failure appears in two places. Langfuse Web serves the UI and the public APIs, and it spikes during large trace queries, exports and bursts of ingestion requests. Langfuse Worker processes asynchronous events, so it is most exposed when ingestion queues grow and a batch of large payloads is processed at once. The two containers have different memory profiles, so one heap setting copied across both is rarely right. Before changing anything, confirm which container restarted, the exact error text, and the container memory limit currently applied to it in your deployment manifest or Compose file.

This page covers how to align the Node.js heap ceiling with the container memory limit so the orchestrator can handle pressure predictably, and how to check that the change holds under load. Starting values and minimum resource figures should come from the Langfuse scaling guide, and you should confirm them against the version you run, since the guide's resource recommendations apply to specific component sizes. Plan the change as a controlled rollout with a rollback path, because a heap setting that is too low trades one crash loop for another.

How the heap ceiling and container limit interact

The diagram starts at the container memory limit, which the orchestrator enforces on the whole process. Inside it, the Node.js heap ceiling set by max-old-space-size caps V8 heap usage, while buffers and native allocations draw from the same container budget outside the heap. If the container limit is reached first, the orchestrator evicts or restarts the container. If the heap ceiling is reached first, the Node.js process aborts with a heap error. Check that the heap ceiling sits below the container limit with room for non-heap memory.

Heap ceiling and container limit both constrain the same Langfuse process.

Which workloads push the heap past its ceiling

Node.js heap exhaustion in Langfuse usually traces back to one of a few workload patterns rather than a single bug. Each cause produces a similar crash, so the useful work is matching the timing and the container that fails against the workload that was running at the time.

Heavy ingestion on the worker

The Langfuse Worker processes asynchronous events, so a burst of traces, observations and scores builds in memory during high-volume periods. Check whether the crash happens in the worker container and whether it clusters around ingestion spikes or scheduled batch sends from SDK clients. A steady climb in memory across a busy period, followed by a restart, points here. Compare the crash time with queue activity before changing any limit.

Large payloads passing through web

The Langfuse Web container handles API requests that carry prompts, completions, tool outputs and attachments. Very large request bodies are parsed and held in memory before they are written onward, so a few oversized traces can spike usage on the web container. Check the web container logs for the request that preceded the crash and whether the failing calls involve unusually large inputs or outputs.

UI queries over large trace histories

Dashboards, trace lists and filtered views can ask the database for wide result sets over long time ranges. The query results are assembled in the web process, so broad filters on large projects can consume heap even when ingestion is quiet. Reproduce the crash by opening the view and widening the date range. If the heap grows only when a particular page is loaded, the cause is the query, not the write path.

Container limit below the Node.js ceiling

Node.js caps its old-generation heap with the max-old-space-size setting, and that cap is independent of the container memory limit. If the cap is higher than the memory the orchestrator allows the container, the kernel or orchestrator kills the process before Node.js can collect garbage. Compare the configured heap size with the container limit in the pod spec or Compose file. A fatal JavaScript heap error means the Node.js cap was reached, while an OOMKilled status with no Node.js message means the container limit was hit first.

Several processes sharing one container

When a container runs more than one Node.js process, or a process manager starts workers that each have their own heap, the total memory use can exceed the container limit even if each process looks reasonable alone. Check the process list inside the container and whether the memory figure is the sum of several heaps. This pattern often appears after a custom image or startup script changes how the application launches, so review the entrypoint before tuning sizes.

Memory growth after an upgrade

A new Langfuse version can change how data is loaded, cached or processed, and a crash that begins right after an upgrade points to the release rather than the traffic. Compare heap behavior on the same workload before and after the change, and check the release notes for the version you moved to. Keep the previous image available so you can roll back while you investigate. Upgrade-driven growth is best confirmed on a staging copy with replayed load.

Langfuse releases

Memory fixes and when each one fits

This table compares the main ways to stop heap crashes in Langfuse web and worker containers, from tuning a single process to changing the topology. Read each row by first confirming where the crash originates, since a heap limit fix does not help if the container is genuinely short of memory or if ClickHouse or PostgreSQL is the component under pressure.

OptionWhen it fitsTrade-offWhat to confirm
Set the Node.js heap ceiling below the container limitThe container is restarted with an out-of-memory error from Node.js while the orchestrator still reports headroom, or the limit was never set on the processNode may collect garbage more often and respond more slowly, and a ceiling set too low can crash a workload that would have fitCurrent container memory limit, the heap flag in use, and whether the limit applies to the web or worker process
Raise the container memory request and limitMemory use grows steadily under normal load and the container is hitting its own limit before Node.js reaches its ceilingHigher reserved memory on the node reduces how many pods fit there, and a larger limit can hide a leakNode capacity for the new limit, and whether memory climbs over time or spikes during specific ingestion bursts
Scale worker replicas on CPU loadWorker containers crash under heavy ingestion, and the scaling guide's CPU-based approach shows sustained load across replicasEach replica carries its own memory footprint, so more replicas add total memory use even as per-pod pressure dropsThe worker CPU and memory trend under load, and the replica ceiling your database and Redis or Valkey can absorb
Split langfuse-web into ingestion and UI deploymentsHeavy trace ingestion starves the user interface, or web crashes coincide with bulk API traffic that the scaling guide describesTwo deployments need separate routing, scaling and resource settings, which adds operational work to maintainWhich request paths reach each deployment, and how your ingress or load balancer routes them
Move ClickHouse to a larger hostCrash traces or logs point to ClickHouse memory pressure, not to the Node.js containers, and the scaling guide's ClickHouse sizing is not metLarger hosts increase infrastructure cost and often require a planned maintenance windowCurrent ClickHouse memory against the scaling guide's minimums, and the query or backfill jobs running at the time of failure
Move PostgreSQL to a larger hostConnection or query pressure from web and worker appears alongside the heap errors and PostgreSQL is near its own memory limitResizing a database host can require downtime or a failover plan, depending on your setupPostgreSQL memory, connection counts and the resource minimums in the scaling guide for your deployment size
Investigate for a memory leak before resizingHeap use rises steadily across days without returning to baseline, regardless of loadDiagnosis takes longer than a resize, and the cause may sit in a version or configuration you must upgradeWhether the Langfuse version in use has known memory issues, and the release notes for the version you plan to run

Where to look first for web and worker crashes

Langfuse Web serves the UI and the public APIs, so its memory use follows request concurrency, large trace and observation queries, and the response payloads the UI and SDK clients pull back. Crashes tend to line up with busy periods, dashboard loads over wide time ranges, or bulk API reads. Start by confirming that the crash is a Node.js heap error rather than an OOM kill from the container runtime, because the two look similar in restart counts but point to different fixes.

  • Container logs: Search for the heap out of memory message and note the timestamp, then compare it with request logs from the same minute.
  • Restart count and last state: A rising restart count with a termination reason of OOMKilled points to the container limit, while a Node.js exit with the heap message points to the runtime heap ceiling.
  • Request pattern: Check whether the crashes follow large exports, wide date ranges in the UI, or a client polling the APIs in a tight loop.
  • Recent changes: Look at upgrades, new SDK integrations and any traffic growth since the last stable period.
  • First change to try: Align the Node.js heap ceiling with the container memory limit, then recheck after a busy period before changing anything else.

Confirm the current minimum resources for the web container in the Langfuse scaling guide before raising limits.

Align the heap ceiling with the container limit

This sequence brings the Node.js heap ceiling under each container's memory limit so the orchestrator handles memory pressure instead of the V8 engine crashing the process. It produces a documented setting for web and worker that you have rolled out one at a time and verified against restart counts and memory graphs.

  1. Collect current limits and restart reasons

    The platform team records the memory request and limit for the langfuse-web and langfuse-worker containers, along with the current replica count, from the Kubernetes manifests, Helm values or Compose file. Then they pull the restart count and last termination reason for each pod or container over the period when the crashes occurred. Tell the reader to note whether the last termination reason is OOMKilled or a Node.js error with a heap message in the logs, because the two point to different causes. The step is done when you have a table with the limit, restart count and termination reason for each container.

  2. Confirm how the heap flag reaches Node.js

    Open the image tag or chart version you run and check how the Node.js heap limit is passed to the process. It may be set as an environment variable such as NODE_OPTIONS, as a command argument, or through a chart value that renders into the container spec. Confirm the exact setting name and accepted format in the Langfuse self-hosting documentation for the release you run, because names and defaults can change between versions. The step is done when you can point to the file or value that sets the heap ceiling and you know which container it applies to.

  3. Set a heap ceiling below the container limit

    Choose a heap ceiling that sits clearly below the container memory limit, leaving room for non-heap memory such as buffers, native modules and the runtime itself. Apply the value separately to web and worker, because their load and memory profiles differ and one value rarely fits both. Write the chosen value, the container limit it was derived from and the reason for the margin into your change record. The step is done when the manifest, values file or Compose file holds the new setting and a dry run or template render shows the expected value in each container.

  4. Roll out the web deployment first

    Apply the change to langfuse-web only and let the rollout complete without changing other settings in the same release. The platform team watches the new pods become ready and confirms that the readiness and liveness checks pass. Keep the change isolated so that any new behavior can be traced to one variable. The step is done when all web replicas run the new configuration and no new restarts have appeared since the rollout finished.

  5. Roll out the worker deployment next

    After web has been stable through a full observation window that your team defines, apply the same kind of change to langfuse-worker. Worker memory often rises with ingestion batches, so confirm the new ceiling still leaves headroom during a busy period, not only at idle. Avoid changing ClickHouse, PostgreSQL or Redis settings in the same step. The step is done when every worker replica runs the new configuration and the rollout has completed cleanly.

  6. Check restart counts after each rollout

    After each rollout, compare the restart counts and last termination reasons with the baseline you recorded in the first step. Look for any OOMKilled status and for heap out-of-memory messages in the container logs. A successful change shows no new restarts from memory causes over the period you defined. The step is done when the restart data for that container matches or improves on the baseline and you have written the result in the change record.

  7. Review memory graphs and document the setting

    Plot working set memory and heap usage for each container over the same window and check that usage stays below the container limit with margin. If memory still climbs toward the limit, the cause may be load or a sizing issue rather than the ceiling, so raise that with the capacity owner instead of only increasing the ceiling. Record the final heap value, container limit, Langfuse version and the date in the runbook so the next upgrade includes a check of the same setting. The step is done when the graphs are saved and the runbook entry names the owner of the setting.

How to confirm the fix holds under load

A heap limit that looks right on paper proves nothing until the container has been pushed with realistic ingestion. Before you call the change finished, replay a representative ingestion load against a test environment that matches production in container limits, worker count and ClickHouse and PostgreSQL sizing. Use trace shapes that reflect your own traffic, including large payloads and bursts, since a light synthetic load can pass while a real spike still kills the process. Run the test long enough for memory to settle into a pattern, not just reach a first peak.

While the load runs, watch three signals on both the web and worker containers: memory use against the container limit, restart counts, and the ingestion queue. Memory should plateau below the limit rather than climb steadily. If pressure persists, the desired outcome is that the orchestrator ends the container for exceeding its memory limit, which shows up as an eviction or OOM-killed status, rather than a Node.js process exiting with a heap abort in the logs. Check the queue as well: it should drain once the load stops. A queue that keeps growing means the worker is losing ground even if it never crashes, and you should confirm that with your own queue metrics or the Langfuse scaling guide before accepting the result.

Treat this validation as recurring work. Memory use can change between Langfuse releases, so repeat the load test after every upgrade, including minor ones, and before moving to a new major version such as the v3 to v4 path described in the Langfuse upgrade guide. Record the baseline heap setting, container limit, and observed peak for each release so a regression is visible at a glance. Ask your platform team to add memory and restart alerts for both containers so that a return of the crash is caught in production, not by a user reporting missing traces.

What to confirm in your environment before changing memory settings

Changing the Node.js heap limit only helps if it matches what your containers, nodes and data stores can actually hold. The cards below cover the checks to run before you touch any memory setting, so the heap change fixes the crash instead of moving it.

Minimum memory and sizing guidance

Start from the memory minimums in the Langfuse scaling guide rather than from guesses. The guide lists minimum resources for web, worker and PostgreSQL, and for ClickHouse in larger deployments. Compare your container memory limits against those minimums and confirm that the limit you plan to raise leaves room for the heap plus non-heap memory the process also uses.

Web and worker minimum
4 GiB
Scaling guide

The exact heap setting your image accepts

Confirm how your image or Helm chart passes the heap limit to Node.js. Some deployments expose a dedicated variable, while others need the flag set through the container's command or environment. Check the chart values or image documentation for the version you run, and verify the setting appears in the running process before you rely on it.

Whether ClickHouse or PostgreSQL is the bottleneck

A crash in the web or worker container does not always mean the Node.js process is at fault. Check ClickHouse and PostgreSQL memory use and their own restarts before raising the heap. If a data store is under memory pressure, a larger heap in the application container only moves the failure to a different component.

Node capacity for larger container limits

Raising container memory limits only works if a worker node has room to schedule them. Confirm allocatable memory on each node, the requests and limits already set on neighboring pods, and whether autoscaling or cluster capacity can add nodes. A pod that cannot be scheduled is a different failure from an OOM kill and needs its own fix.

How your orchestrator reports OOM kills

Find out how your platform records a container killed for exceeding its memory limit, including the exit reason, restart count and event messages. Kubernetes, Docker and VM-based setups each expose this differently. Knowing the signal lets you confirm the fix worked and separate a Node.js heap error, which the process logs itself, from a kernel kill by the container runtime.

Whether your version matches the guidance

Check that the Langfuse version you run is the one the scaling and resource guidance describes. Memory use changes between releases, and major upgrades also change the data model and infrastructure requirements. Record your running version from the deployment before comparing numbers, and confirm any version-specific requirement in the release notes before you change settings.

Langfuse releases

Operational risks of raising memory limits

Raising a memory limit without changing the workload moves the failure somewhere else. The risk is that a higher container limit or a higher heap ceiling lets one Langfuse container grow until it competes with its neighbors for memory on the same node. Before raising --max-old-space-size or the container limit, check the node's allocatable memory and the sum of the limits of every pod or container scheduled there, including PostgreSQL, ClickHouse and Redis or Valkey. If the total limits exceed what the node can hold, the kernel may evict or kill other workloads, and the crash you see moves from the Node.js process to a neighbor that was never misbehaving.

The opposite mistake hides a problem. A heap ceiling set well above what the process needs lets a memory leak or an unbounded batch grow for hours before anything fails, and by then the orchestrator may restart the container mid-job or the node may run out of memory entirely. Ask the team that owns the Langfuse build whether the heap growth you observe is expected for your ingestion volume or indicates a leak, and do not treat a raised ceiling as the end of the investigation. Going the other way, a ceiling set too low for normal load produces repeated crashes under ordinary traffic, so the target is a value that leaves headroom for typical peaks without masking growth.

Track memory for each Langfuse web and worker container over time, not just at the moment of a crash. Record the working set, the heap usage where your monitoring exposes it, restart counts and the reasons for restarts, and compare them before and after each change. Keep the values for NODE_OPTIONS, the container memory requests and limits, and replica counts in version control next to the rest of your deployment manifests, so every change has an author, a reason and a rollback path. Confirm with your platform team which metrics and alerts your monitoring stack already collects for Langfuse before you rely on them.

Questions teams ask about Langfuse memory errors

What drives the cost of fixing JavaScript heap out of memory errors in Langfuse?

The cost depends mostly on how many containers are affected, how many environments need the change, and how much evidence the client needs for its change record. A narrow fix covers the web and worker containers in one environment, with the memory limits and Node.js heap flag reviewed together. Costs rise when the team must also investigate recurring crashes under load, review ClickHouse and PostgreSQL sizing, or document the change for an internal risk or compliance review. Ask any partner for a quote built from a written scope that lists the containers, environments, deliverables and retest steps. Once the fix is in place, the recurring cost is mainly the time your team spends watching memory metrics after each release.

How long does diagnosis usually take for Langfuse heap crashes?

Diagnosis time depends mainly on whether the team can read container logs, restart events and memory metrics for the web and worker containers. If those signals are available in your monitoring stack, the cause is often clear quickly, because the crash shows up as a Node.js heap limit error close to a container memory limit. If the team has only pod status or no metrics history, the work takes longer because the crashes must be reproduced under realistic ingestion. Access to a staging copy of the deployment also shortens the work. Ask the provider to confirm which logs, metrics and environments they need before the diagnosis window is agreed.

What does the work need from our platform team?

The work needs read access to the deployment manifests or Helm values for the web and worker containers, the current memory requests and limits, and recent container restart history. It also needs access to logs and memory metrics for the period when crashes occurred, plus a change window for applying and verifying the new settings. Your platform team should confirm who owns the Kubernetes or VM configuration, how changes are reviewed, and whether a staging environment matches production limits. Without these inputs, the fix can only be proposed, not verified. Agree the access list in writing before the engagement starts.

Can an internal team fix Langfuse heap errors without an outside partner?

Yes, many internal platform teams can make this change alone, because the core task is to set the Node.js heap limit for each container so it stays below the container memory limit, then confirm the orchestrator restarts a container cleanly under pressure. The skills needed are container resource management, reading Node.js crash output and running a controlled load test. Teams without those skills, or without a way to reproduce ingestion load, often spend more time on trial and error. Consider a partner when the crashes recur after a fix, when several environments must match, or when the change needs documented verification for an audit.

When does a support contract matter for Langfuse memory problems?

A support contract matters most when memory failures affect production trace ingestion and your team needs a defined response path. Langfuse's self-hosted pricing page lists a custom-priced Self-Hosted Enterprise plan that adds a named support engineer, solutions architect access and a support SLA, so ask Langfuse which of those terms apply to your plan. A retainer from an implementation partner covers different work, such as monitoring, tuning after each release and retesting. Check what each contract covers before you assume it handles heap tuning, because vendor support and partner support often answer different questions.

What changes after a major Langfuse upgrade for heap and memory settings?

A major upgrade can change the memory profile of the web and worker containers, so the heap settings should be reviewed again rather than assumed to carry over. Langfuse's v3 to v4 guide requires ClickHouse 25.12 or later, PostgreSQL 15 or later and Redis 7.0 or later, and it moves to an observations-first ClickHouse data model. It also advises about 3x ClickHouse disk headroom when backfilling historic data, and backfill work can increase load during the upgrade window. Plan a load test on the new version in staging, recheck container limits after the upgrade, and confirm the migration guide steps before you change production.

How DeployOpen scopes and supports Langfuse memory fixes

DeployOpen approaches Node.js heap fixes in self-hosted Langfuse as a scoped infrastructure change, not a one-off container tweak. We start from the web and worker containers you run in your own cloud accounts, data centers or air-gapped networks, and we align heap limits with the memory limits your orchestrator enforces.

How we scope

  • Inventory the web and worker containers, their current memory limits and the restart history in your environment
  • Agree in writing which deployments, namespaces or Compose services are in scope for heap and limit changes
  • Define how the work is verified, including load conditions and the evidence you receive before sign-off
  • Engagements are fixed-scope, with scope, deliverables and timelines agreed before work starts; ongoing support is available as a retainer

How we build

  • Set the Node.js old-space limit below each container's memory limit so the process fails in a controlled way
  • Adjust container memory requests and limits together with the heap setting, based on observed usage in your cluster
  • Test the change against your ingestion pattern in a non-production environment before it reaches production
  • Check that PostgreSQL, ClickHouse and blob storage sizing is reviewed alongside the application containers where pressure appears

How we hand over

  • Document the final heap settings, memory limits, the reasoning behind each value and the rollback steps
  • Provide the configuration as code or manifest changes that your team can review and store in your own repository
  • Walk your platform and on-call engineers through the signals that show memory pressure and the restart behavior to expect
  • Deliver a written handover with open items, owners and the upgrade checks to repeat when you move Langfuse versions

How we support

  • Re-check heap and memory settings after Langfuse upgrades, since container footprints can change between releases
  • Retest after changes to ingestion volume, worker counts or the move to split web deployments
  • Offer ongoing support and upgrades as a retainer, with scope agreed in writing for each period
  • Confirm with your team which monitoring and alerting you already run, so new findings feed your existing operations

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.