deepseek-ai/deepseek-harness · error · Error

dynamic package `${half}` failed to parse: ${context} Note:

Error message

dynamic package `${half}` failed to parse:
${context}
Note: it runs as the BODY of an async function (line numbers are offset by the 1-line wrapper). Check bracket balance — ending the returned plugin object with `});` closes a call that was never opened; a plain `return { … }` ends with `}` (an optional `;`), never `).

What it means

Error "dynamic package `${half}` failed to parse: ${context} Note: it runs as the BODY of an async function (line numbers are offset by the 1-line wrapper). Check bracket balance — ending the returned plugin object with `});` closes a call that was never opened; a plain `return { … }` ends with `}` (an optional `;`), never `)." thrown in deepseek-ai/deepseek-harness.

Source

Thrown at packages/extensions/cordis-host-runner/src/sandbox.ts:220

 * Node host its failure carries the source-line-and-caret prelude the
 * teaching text builds on, and where the vm is a stub the message stays bare.
 * The two parsers' syntax faces differ at the margin (`new.target` parses in
 * a function body but not at the vm wrapper's top level), an accepted cost of
 * a vm-free gate; and under a page CSP without `'unsafe-eval'`, `new Function`
 * throws `EvalError`, which propagates unwrapped.
 * @param code - the model-written function body.
 * @param half - which define argument carried it, for the error text.
 * @throws when the body does not parse, with the offending line and a teaching hint.
 */
export function precheckCode(code: string, half: 'code.host' | 'code.client'): void {
  const wrapped = `(async () => {\n${code}\n})()`
  try {
    // Compile-only: constructing the function parses the source and runs nothing.
    // oxlint-disable-next-line typescript/no-implied-eval -- parse gate over model-written code; nothing is invoked
    new Function(wrapped)
  } catch (error) {
    if (!isSyntaxError(error)) throw error
    throw new Error(parseErrorMessage(half, prettyParseContext(wrapped, half, error)))
  }
}

/**
 * Best-effort vm recompile of a body `new Function` already refused, for the
 * source-line-and-caret prelude only.
 * @param wrapped - the wrapped source that failed to parse.
 * @param half - which define argument carried it, for the vm filename.
 * @param refusal - the gate's own `SyntaxError`, the fallback context source.
 * @returns the vm prelude when a real vm produced one, else the bare refusal.
 */
function prettyParseContext(wrapped: string, half: 'code.host' | 'code.client', refusal: Error): string {
  try {
    new Script(wrapped, { filename: `cordis-dyn-${half}.js` })
  } catch (vmError) {
    if (isSyntaxError(vmError)) return syntaxErrorContext(vmError)
    // A stubbed vm (the browser worker) refuses Script itself; the gate's
    // error is the only context there is.

View on GitHub (pinned to b150a551b8)

When it happens

Trigger: Thrown at packages/extensions/cordis-host-runner/src/sandbox.ts:220 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of deepseek-ai/deepseek-harness@b150a551b8 (2026-08-24). Data as JSON: /api/errors/ad658a014c7d4699. Report an issue: GitHub.