lutzroeder/netron · error · Error

64-bit value 0x${this.toString(16)} exceeds safe integer.

Error message

64-bit value 0x${this.toString(16)} exceeds safe integer.

What it means

This error is thrown by the Web Worker's message dispatcher when it receives a postMessage whose `type` field does not match any case in its switch statement. The worker only handles the message type 'dagre.layout'; any other value falls into the default branch and throws. Because the throw happens inside the worker's message listener (not inside the inner try/catch), the error is not posted back to the main thread — it surfaces as an unhandled error in the worker context.

Source

Thrown at source/base.js:22

base.Complex = class Complex {

    constructor(real, imaginary) {
        this.real = real;
        this.imaginary = imaginary;
    }

    toString(/* radix */) {
        const sign = this.imaginary < 0 ? '-' : '+';
        const imaginary = Math.abs(this.imaginary);
        return `${this.real} ${sign} ${imaginary}i`;
    }
};

/* eslint-disable no-extend-native */

BigInt.prototype.toNumber = function() {
    if (this > Number.MAX_SAFE_INTEGER || this < Number.MIN_SAFE_INTEGER) {
        throw new Error(`64-bit value 0x${this.toString(16)} exceeds safe integer.`);
    }
    return Number(this);
};

if (!DataView.prototype.getFloat16) {
    DataView.prototype.getFloat16 = function(byteOffset, littleEndian) {
        const value = this.getUint16(byteOffset, littleEndian);
        const e = (value & 0x7C00) >> 10;
        let f = value & 0x03FF;
        if (e === 0) {
            f = 0.00006103515625 * (f / 1024);
        } else if (e === 0x1F) {
            f = f ? NaN : Infinity;
        } else {
            f = DataView.__float16_pow[e] * (1 + (f / 1024));
        }
        return value & 0x8000 ? -f : f;
    };

View on GitHub (pinned to d8a543f5f8)

Solutions

  1. Check the exact string you pass as `type` in postMessage — it must be exactly 'dagre.layout' (case-sensitive).
  2. Verify the worker script you instantiated matches the client version (no stale cached or mismatched bundle) so client and worker agree on the message protocol.
  3. If you need init/cancel/error-control messages, extend the switch in source/worker.js to handle them instead of letting them hit default.
  4. Wrap the throw in the default case with a postMessage error reply (like the dagre.layout case does) so failures propagate to the main thread instead of dying silently in the worker.

Example fix

// before
worker.postMessage({ type: 'layout', nodes, edges }); // throws: Unsupported message type 'layout'

// after
worker.postMessage({ type: 'dagre.layout', nodes, edges, layout, state });
Defensive patterns

Strategy: type-guard

Validate before calling

const SUPPORTED_MESSAGE_TYPES = ['dagre.layout'];
function isSupportedMessage(payload) {
  return payload != null && SUPPORTED_MESSAGE_TYPES.includes(payload.type);
}
if (isSupportedMessage(msg)) worker.postMessage(msg);
else console.warn('Unsupported worker message:', msg.type);

Type guard

function isDagreWorkerMessage(data) {
  return typeof data === 'object' && data !== null && typeof data.type === 'string' && data.type === 'dagre.layout';
}

Try / catch

// Note: this throw happens inside the worker, not on the calling thread.
// Listen for worker errors and mismatch replies instead of try/catching postMessage:
worker.addEventListener('error', (e) => console.error('worker error:', e.message));
worker.onmessage = (e) => {
  if (e.data && e.data.type === 'error') console.error('layout failed:', e.data.message);
};

Prevention

When it happens

Trigger: Calling worker.postMessage({ type: 'anything-other-than-dagre.layout', ... }) — e.g. posting 'layout', 'dagre', 'run', or an init/abort message the worker does not implement. It also fires when the payload is not the expected envelope at all (e.g. posting a raw object or string without a `type` field, giving type 'undefined').

Common situations: Version mismatch between the main-thread client code and the worker script (newer client sends message types the older worker doesn't know), typos in the message type string, sending handshake/init/termination control messages to a worker that only implements layout, or accidentally posting to the wrong worker instance (e.g. a generic pool worker receiving dagre messages).


AI-assisted analysis of lutzroeder/netron@d8a543f5f8 (2026-08-27). Data as JSON: /api/errors/ce8b64f586ff3d43. Report an issue: GitHub.