<p>We have the following code (don't ask me why...even as none-javascript dev it doesn't look pretty to me), which throws error after Kubernetes upgrade:</p>
<pre><code>module.exports.getReplicationControllers = async function getReplicationControllers(namespace) {
  const kubeConfig = (await getNamespacesByCluster()).get(namespace);
  if (!kubeConfig) throw new Error(`No clusters contain the namespace ${namespace}`)
  const kubeConfigEscaped = shellEscape([kubeConfig]);

  const namespaceEscaped = shellEscape([namespace]);
  const result = await cpp(`kubectl --kubeconfig ${kubeConfigEscaped} get replicationcontrollers -o json -n ${namespaceEscaped}`);
  console.error(result.stderr);
  /** @type {{items: any[]}} */
  const resultParsed = JSON.parse(result.stdout);
  const serviceNames = resultParsed.items.map((item) =&gt; item.metadata.name);
  return serviceNames;
}
</code></pre>
<blockquote>
<p>ChildProcessError: stdout maxBuffer length exceeded kubectl --kubeconfig /kubeconfig-staging get replicationcontrollers -o json -n xxx (exited with error code ERR_CHILD_PROCESS_STDIO_MAXBUFFER)</p>
</blockquote>
<p>What I've tried so far is:</p>
<pre><code>  const result = await cpp(`kubectl --kubeconfig ${kubeConfigEscaped} get replicationcontrollers -o=jsonpath='{.items[*].metadata.name}' -n ${namespaceEscaped}`);
  console.error(result.stderr);
  const serviceNames = result.split(' ');
  return serviceNames;
</code></pre>
<p>Which returns</p>
<blockquote>
<p>TypeError: result.split is not a function</p>
</blockquote>
<p>I am not super versed with JavaScript, any help appreciated.</p>

Anton Kim
<p><strong>Answering the question in general</strong> (rather than getting you to switch to a different tool), for people who have this question and may be using other apps:</p>
<blockquote>
<p>RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded</p>
</blockquote>
<p><strong>The issue is caused by your command sending a lot of data (more than 1MB) to stdout or stderr.</strong></p>
<p>Increase the <code>maxBuffer</code> option in exec() for <a href="https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback" rel="nofollow noreferrer">the node docs for process.exec</a></p>
<pre><code>exec(someCommand, {
  maxBuffer: 5 * 1024 * 1024,
})
</code></pre>
