deepseek-ai/deepseek-harness · critical
client-modules: ${CLIENT_MODULES_ID}/client.js requested ext
Error message
client-modules: ${CLIENT_MODULES_ID}/client.js requested external "${specifier}" before the module system existed What it means
Thrown while the bootstrap bundle's factory executes inside window.__ModuleLoader__.create(). The only require available at that instant is a stub whose every call throws, because the shared module table does not exist until createClientModuleSystem returns. Any external module the '@deepseek-ai/dsh-client-modules' client bundle requests synchronously at factory time — instead of bundling it privately or deferring the import — trips this error. It is a build/packaging defect in the bootstrap bundle, not a condition runtime callers create.
Source
Thrown at packages/client/modules/src/index.ts:256
* @param graph - the composed entry graph.
* @returns head rows in execution order: queue script, preload scripts, graph global.
*/
export function bootInjections(graph: WebBootGraph): IndexInjection[] {
const bootstrapId = JSON.stringify(CLIENT_MODULES_ID)
const queue = `(()=>{
const pendingQueue=[]
window.__ModuleLoader__={
mode:"queue",
pendingQueue,
load(registration){pendingQueue.push(registration)},
create(options){
if(this.mode!=="queue")throw new Error("client-modules: window.__ModuleLoader__.create called after module-system boot")
const index=pendingQueue.findIndex(registration=>registration.id===${bootstrapId})
const registration=pendingQueue[index]
if(registration===undefined)throw new Error("client-modules: HTML did not preload ${CLIENT_MODULES_ID}/client.js")
pendingQueue.splice(index,1)
const exports=registration.factory(specifier=>{
throw new Error('client-modules: ${CLIENT_MODULES_ID}/client.js requested external "'+specifier+'" before the module system existed')
})
if(typeof exports!=="object"||exports===null||typeof exports.createClientModuleSystem!=="function"||typeof exports.apply!=="function"){
throw new Error("client-modules: ${CLIENT_MODULES_ID}/client.js did not export the bootstrap module face")
}
return exports.createClientModuleSystem(this,{id:registration.id,exports},options)
}
}
})()`
const preload = PARSER_PRELOAD_IDS.map(id => graph.entries.find(entry => entry.id === id))
.filter((entry): entry is WebBootEntry => entry !== undefined)
.map((entry): IndexInjection => ({ kind: 'script-src', placement: 'head', src: entry.url }))
return [
{ kind: 'script', placement: 'head', text: queue },
...preload,
{ kind: 'global', name: '__DSH_BOOT__', value: graph },
]
}
View on GitHub (pinned to b150a551b8)
Solutions
- Rebuild the bootstrap bundle from current sources: `pnpm --filter @deepseek-ai/dsh-client-modules bundle` (or a full `pnpm run build`) and hard-reload.
- Inspect the client bundle preset (packages/client tsdown config) for an `external` entry covering a module the bootstrap half imports as a value at top level; remove it or make the import lazy so the request happens after the system exists.
- Smoke the artifact offline: evaluate lib/client.js in a VM under a queue stub and invoke the factory with a throwing require — any factory-time request throws by construction.
- Confirm no stale copy of client.js is being served (rev query mismatch, copied static directory).
Example fix
// before — tsdown.client.ts externalizes a value import for the bootstrap bundle
clientBundle('modules', ['lib/types/index.js'], { external: ['@deepseek-ai/dsh-client-runtime'] })
// after — the bootstrap bundle stays self-contained at factory time
clientBundle('modules', ['lib/types/index.js']) Defensive patterns
Strategy: try-catch
Validate before calling
import vm from 'node:vm'
import { readFileSync } from 'node:fs'
// offline smoke: the bootstrap factory must not request externals before the system exists
const src = readFileSync('packages/client/modules/lib/client.js', 'utf8')
const pendingQueue = []
const sandbox = { window: { __ModuleLoader__: { mode: 'queue', load: r => pendingQueue.push(r) } } }
vm.createContext(sandbox)
vm.runInContext(src, sandbox)
const reg = pendingQueue.find(r => r.id === '@deepseek-ai/dsh-client-modules')
reg.factory(spec => { throw new Error(`premature external request: ${spec}`) }) // must not throw Try / catch
try {
system = window.__ModuleLoader__.create(options)
} catch (error) {
reportBootFailure(error) // advise rebuilding @deepseek-ai/dsh-client-modules and hard-reloading
throw error
} Prevention
- Keep the bootstrap client bundle free of factory-time external requests: bundle dependencies privately or defer imports until after boot.
- Run the keyless web replay smoke after touching bundler configuration.
- Rebuild all client packages together; avoid partial builds across protocol changes.
When it happens
Trigger: The built lib/client.js of dsh-client-modules carries an externalized top-level value import, so its factory calls the stub require(specifier) during create(). Typical causes: a bundler-config regression that externalizes a module the bootstrap half imports at factory scope, a hand-edited tsdown.client.ts external list, or version skew where an old bundle is paired with the current HTML queue protocol.
Common situations: Upgrading the client bundling toolchain and forgetting that the bootstrap bundle must stay self-contained at factory time; locally adding an `external` entry to speed up builds; partial `pnpm run build` after protocol changes leaving one stale bundle.
Related errors
- client-modules: HTML did not preload ${CLIENT_MODULES_ID}/cl
- client-modules: ${CLIENT_MODULES_ID}/client.js did not expor
- browser operating-system launcher exited with code ${String(
- client-modules: window.__DSH_BOOT__ is missing or not an obj
- web boot: window.__ModuleLoader__ bootstrap facade is missin
AI-assisted analysis of deepseek-ai/deepseek-harness@b150a551b8 (2026-08-24).
Data as JSON: /api/errors/4498c126c288d286.
Report an issue: GitHub.