Hmbown/CodeWhale · error · Error
Missing core module
Error message
Missing core module
What it means
pet-native.js embeds a tiny CommonJS-style module loader at the bottom of its IIFE: `load(id)` normalizes the id, checks a `factories` registry, and throws Error('Missing core module') when the requested id was never registered in `factories`. This is an internal wiring guard — only module ids statically listed in the bundle's factories map are loadable, and the entry point does `global.PetNative=load('pet-native').PetNative`.
Solutions
- Compare the id passed to load() (or the failing internal require) against the keys actually registered in the `factories` object in pet-native.js; fix the id or add the missing factory.
- If a module was renamed/split, update all load()/require call sites to the new id and ensure the factory function `factories[id](e,load)` signature matches.
- If a build/concat step assembles this bundle, verify it emits every module's factory block and that the entry `load('pet-native')` id matches a registered key.
- Add a console.log(Object.keys(factories)) before the throw while debugging to see which ids exist at runtime.
Example fix
// before
function load(id){id=id.replace(/^\.\//,'').replace(/\.js$/,'');if(cache[id])return cache[id];if(!factories[id])throw Error('Missing core module');...}
const settings = load('./config'); // factories has 'config-core', not 'config'
// after
const settings = load('./config-core'); // id matches a registered factory key
// (or register the missing factory:) factories['config'] = function(exports, require){ ... }; Defensive patterns
Strategy: type-guard
Validate before calling
// Callers of the loader / wrapper API:
function canLoad(id) {
const norm = id.replace(/^\.\//, '').replace(/\.js$/, '');
return typeof globalThis.PetNative !== 'undefined' && norm.length > 0;
}
// For maintainers editing the bundle: assert registration at startup
if (typeof factories['pet-native'] !== 'function') throw new Error('pet-native factory missing'); Type guard
function isLoadedModule(id) {
return typeof id === 'string' && typeof cache[id.replace(/^\.\//, '').replace(/\.js$/, '')] !== 'undefined';
} Try / catch
try {
const mod = load(id);
use(mod);
} catch (err) {
if (err.message === 'Missing core module') {
console.error(`Module "${id}" is not registered; available: ${Object.keys(factories)}`);
} else throw err;
} Prevention
- Keep module ids and factory registrations in one table and derive load() calls from it.
- When renaming/splitting a module, grep the bundle for all load()/require sites of the old id.
- Add a startup smoke test that loads every registered module id.
- If a build step assembles factories, verify all blocks are emitted with a key-count check.
When it happens
Trigger: The loader is called with an id that has no entry in the `factories` object: a require-style call such as load('helper') where the helper module was renamed, its `.js` suffix handling stripped differently (e.g. load('./helper.js') after the regex strips it — but a call passing 'subdir/helper' when factories only registers 'helper'), or a refactor removed a module's factory registration while another module still loads it. Also triggered if the bundle was partially generated/concatenated, dropping one module's factory block.
Common situations: A developer renames or splits a module in the pet-native bundle but forgets to register the new factory under the expected key; a build step that assembles modules out of order or drops one; a typo in the id string passed to load() (e.g. 'pet-native-core' vs 'pet-native'); tree-shaking or minification removing what looks like dead factory code.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- Archive the legacy recording before accepting more…
- Choose an appearance file smaller than 4 KiB.
- Create lookups always yield a table
- foreground shell did not return a process id
- generated invalid permissions document for
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/f467a857744f7152.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tui/pet_watch/pet-native.js:2532
trace.append(records);
return trace.snapshot();
}
/** The journal owns request state until a matching terminal receipt. A live
* driver may confirm that state only while its cursor-checked stream is healthy.
* Ordinary open tool spans remain unknown-duration; no execution is inferred. */
function observeRuntimeRequests(trace, observedThrough) {
const origin = Date.parse(trace.originTime ?? '');
if (trace.metadata.sourceFormat !== 'codewhale.runtime-events/v2' || !Number.isFinite(origin)
|| !Number.isFinite(observedThrough))
throw new Error('Invalid Runtime observation horizon.');
const at = observedThrough - origin;
const events = trace.events.map(e => e.openEnded && e.attributes['whalesong.waiting'] === true && at >= e.startTime
? { ...e, endTime: at, openEnded: false } : e);
return { ...trace, events, duration: Math.max(trace.duration, at) };
}
};
function load(id){id=id.replace(/^\.\//,'').replace(/\.js$/,'');if(cache[id])return cache[id];if(!factories[id])throw Error('Missing core module');const e=cache[id]={};factories[id](e,load);return e;}
global.PetNative=load('pet-native').PetNative;
})(globalThis);
View on GitHub (pinned to 73e0f67d83)