BigPizzaV3/CodexPlusPlus · error · Error

当前 Codex 版本未提供兼容的 HTTP 服务

Error message

当前 Codex 版本未提供兼容的 HTTP 服务

What it means

After loading the native runtime, nativeApiRequest() verifies the expected binding native.lGt is a function. If it is missing, this Codex build does not expose the compatible HTTP service and the error is thrown with canvasApiLocal set.

Solutions

  1. Update the userscript to a version matching your Codex build
  2. Downgrade/align Codex to a version the script supports
  3. Use the external API channel instead of native
  4. Inspect the runtime object to confirm which bindings exist and report/patch the script
Defensive patterns

Strategy: try-catch

Validate before calling

const native=await loadNativeRuntime().catch(()=>null);
if(typeof native?.lGt!=='function') alert('update userscript');

Type guard

function hasHttpBinding(n){return !!n && typeof n.lGt==='function';}

Try / catch

try{ await nativeApiRequest(url,opts) }catch(e){ if(e.message.includes('兼容的 HTTP 服务')){ reportVersionMismatch(); useExternalChannel(); } }

Prevention

When it happens

Trigger: loadNativeRuntime() succeeded but the returned object lacks a callable lGt (binding renamed or removed in this Codex version).

Common situations: Codex internal API surface changed between versions; script pinning outdated binding names; partial/failed host update leaving mismatched runtime.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/537cab11ed404427. Report an issue: GitHub.

Appendix: source

Thrown at tools/conversation-canvas/public/canvas.user.js:767

        clearInterval(heartbeat);
        signal?.throwIfAborted();
        if(!error.retryable||attempt>=maxRetries)throw error;
        const delay=retryDelayMs*2**attempt;
        progress(`${error.message};${Math.ceil(delay/1000)} 秒后自动重试 ${attempt+1}/${maxRetries}(可能重复计费)…`);
        // Pausing during backoff must not submit another request.
        let timer;try{await waitForApi(new Promise(resolve=>{timer=setTimeout(resolve,delay);}),signal);}finally{clearTimeout(timer);}
      }finally{clearInterval(heartbeat);}
    }
  }
  return {run,dispose};
}

// HTTP uses the app host, with versioned runtime bindings, not renderer fetch/CSP.
async function nativeApiRequest(url,options){
  const localError=message=>Object.assign(Error(message),{canvasApiLocal:true});
  let native;
  try{native=await loadNativeRuntime();}catch{throw localError('当前 Codex 版本的 API 适配器不兼容,请更新对话脉络脚本');}
  if(typeof native.lGt!=='function')throw localError('当前 Codex 版本未提供兼容的 HTTP 服务');
  native.lGt();
  const client=native.cGt?.getInstance?.();
  if(typeof client?.fetch!=='function'||!native.jR?.httpFetch)throw localError('当前 Codex 的 HTTP 服务尚未就绪,请稍后重试');
  const {onProgress,...fetchOptions}=options;
  const response=await client.fetch(url,fetchOptions);
  return readApiResponse(response,options.signal,onProgress);
}


const canvasNodeSize={width:268,height:132,gapX:88,gapY:34};

// Iterative preorder/reverse traversal keeps deep histories off the JS call stack.
function layoutTaskCanvas(nodes,currentNodeId,collapsed=new Set()){
  const view=visibleTreeRows(nodes,currentNodeId,collapsed),children=new Map(),positions=new Map();
  const {width,height,gapX,gapY}=canvasNodeSize;
  for(const row of view.rows){const list=children.get(row.node.parent)||[];list.push(row.node.id);children.set(row.node.parent,list);}
  let leaf=0;
  for(const row of view.rows)if(!children.has(row.node.id))positions.set(row.node.id,leaf++*(height+gapY));

View on GitHub (pinned to b1ed92e5e4)