koala73/worldmonitor · warning

Worksheet JSON must be no larger than 64 KiB.

Error message

Worksheet JSON must be no larger than 64 KiB.

What it means

The operational exposure form's file-import handler rejects any selected worksheet JSON file larger than MAX_OPERATIONAL_JSON_BYTES (64 KiB) before it is parsed. The check runs on selected.size immediately after the change event, so oversized files never reach importOperationalWorksheet.

Solutions

  1. Reduce the worksheet's size: remove extra fields, whitespace, or embedded data before re-exporting.
  2. Re-export the worksheet from the form's export button instead of importing an unrelated large JSON file.
  3. Minify the JSON (strip indentation) if it is under the limit once pretty-printing is removed.
  4. Split inputs across multiple worksheets if the model genuinely needs more than 64 KiB of input.

Example fix

// before
const text = await selected.text();
const imported = importOperationalWorksheet(text);
// after
if (selected.size > 64 * 1024) {
  const minified = JSON.stringify(JSON.parse(await selected.text()));
  if (minified.length > 64 * 1024) throw new Error('Worksheet JSON must be no larger than 64 KiB.');
  var imported = importOperationalWorksheet(minified);
} else {
  var imported = importOperationalWorksheet(await selected.text());
}
Defensive patterns

Strategy: validation

Validate before calling

const input = document.querySelector('input[type=file]');
input.addEventListener('change', () => {
  const f = input.files?.[0];
  if (f && f.size > 64 * 1024) { alert('Worksheet must be ≤ 64 KiB'); input.value = ''; }
});

Try / catch

try {
  await importWorksheet(file);
} catch (e) {
  if (e.message.includes('64 KiB')) setStatus('File too large — export a smaller worksheet (≤ 64 KiB).');
  else setStatus('Import rejected; your inputs are unchanged.');
}

Prevention

When it happens

Trigger: Selecting a worksheet .json file in the import file input whose size exceeds 64 KiB (65536 bytes), regardless of content validity.

Common situations: Exporting a worksheet from a session with many inputs/history and re-importing it; hand-edited worksheets with embedded data dumps; importing a full dashboard export instead of the single worksheet export.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of koala73/worldmonitor@7d06c8633d (2026-09-15). Data as JSON: /api/errors/5b53ce0cf03761fc. Report an issue: GitHub.

Appendix: source

Thrown at src/components/OperationalExposureForm.ts:147

    editor.append(section);
  }
  editor.prepend(h('section', { className: 'operational-input-section' }, h('h3', {}, 'Operation inputs'), fields));
  root.append(h('header', { className: 'operational-header' },
    h('p', { className: 'operational-eyebrow' }, 'LOCAL WORKSHEET'),
    h('h2', { className: 'cdp-card-title' }, 'Operational what-if'),
    h('p', { className: 'cdp-section-description' }, 'Compare usable stock, daily demand and delivery timing. Edit the labeled example to test your assumptions.')));
  root.addEventListener('input', event => {
    if (event.target instanceof HTMLInputElement && event.target.type !== 'file') { event.target.setCustomValidity(''); basis = 'user'; update(); }
  });
  const file = input('Import worksheet JSON', 'file', actions);
  file.accept = '.json,application/json';
  file.addEventListener('change', async () => {
    const selected = file.files?.[0];
    if (!selected) return;
    const current = revision;
    const generation = ++importGeneration;
    try {
      if (selected.size > MAX_OPERATIONAL_JSON_BYTES) throw new Error('Worksheet JSON must be no larger than 64 KiB.');
      const imported = importOperationalWorksheet(await selected.text());
      if (signal?.aborted || generation !== importGeneration) return;
      if (current !== revision) throw new Error('Inputs changed while reading. Select the file again to import.');
      populate(imported.input); importStatus.textContent = 'Worksheet imported. Results recalculated from its inputs.';
    } catch (cause) {
      importStatus.textContent = `Import rejected; your inputs are unchanged. ${cause instanceof Error ? cause.message : 'Invalid JSON.'}`;
    } finally { if (generation === importGeneration) file.value = ''; }
  });
  exportButton.addEventListener('click', () => {
    if (!snapshot) return;
    const url = URL.createObjectURL(new Blob([JSON.stringify(snapshot, null, 2)], { type: 'application/json' }));
    h('a', { href: url, download: 'operational-worksheet.json' }).click();
    setTimeout(() => URL.revokeObjectURL(url), 30_000);
  });
  actions.append(exportButton);
  root.append(actions, importStatus,
    h('details', { className: 'operational-method operational-input-help' }, h('summary', {}, 'How this worksheet works'),
      h('p', {}, 'Actual operating data is optional. Inputs stay in browser memory until page reload; export JSON to keep them. Use one unit for all quantities. Changing the unit relabels all quantities; it does not convert them. Up to 90 days and 30 deliveries per list. Quantities and costs allow 0-1 million with up to 6 decimal places.')),

View on GitHub (pinned to 7d06c8633d)