{"record":{"id":"ce8b64f586ff3d43","repo":"lutzroeder/netron","slug":"64-bit-value-0x-this-tostring-16-exceeds-safe-i","errorCode":null,"errorMessage":"64-bit value 0x${this.toString(16)} exceeds safe integer.","messagePattern":"64-bit value 0x(.+?) exceeds safe integer\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"source/base.js","lineNumber":22,"sourceCode":"base.Complex = class Complex {\n\n    constructor(real, imaginary) {\n        this.real = real;\n        this.imaginary = imaginary;\n    }\n\n    toString(/* radix */) {\n        const sign = this.imaginary < 0 ? '-' : '+';\n        const imaginary = Math.abs(this.imaginary);\n        return `${this.real} ${sign} ${imaginary}i`;\n    }\n};\n\n/* eslint-disable no-extend-native */\n\nBigInt.prototype.toNumber = function() {\n    if (this > Number.MAX_SAFE_INTEGER || this < Number.MIN_SAFE_INTEGER) {\n        throw new Error(`64-bit value 0x${this.toString(16)} exceeds safe integer.`);\n    }\n    return Number(this);\n};\n\nif (!DataView.prototype.getFloat16) {\n    DataView.prototype.getFloat16 = function(byteOffset, littleEndian) {\n        const value = this.getUint16(byteOffset, littleEndian);\n        const e = (value & 0x7C00) >> 10;\n        let f = value & 0x03FF;\n        if (e === 0) {\n            f = 0.00006103515625 * (f / 1024);\n        } else if (e === 0x1F) {\n            f = f ? NaN : Infinity;\n        } else {\n            f = DataView.__float16_pow[e] * (1 + (f / 1024));\n        }\n        return value & 0x8000 ? -f : f;\n    };","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/lutzroeder/netron/blob/d8a543f5f847ef596aa58858d6adcf5d75545f7f/source/base.js#L4-L40","documentation":"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.","triggerScenarios":"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').","commonSituations":"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).","solutions":["Check the exact string you pass as `type` in postMessage — it must be exactly 'dagre.layout' (case-sensitive).","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.","If you need init/cancel/error-control messages, extend the switch in source/worker.js to handle them instead of letting them hit default.","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."],"exampleFix":"// before\nworker.postMessage({ type: 'layout', nodes, edges }); // throws: Unsupported message type 'layout'\n\n// after\nworker.postMessage({ type: 'dagre.layout', nodes, edges, layout, state });","handlingStrategy":"type-guard","validationCode":"const SUPPORTED_MESSAGE_TYPES = ['dagre.layout'];\nfunction isSupportedMessage(payload) {\n  return payload != null && SUPPORTED_MESSAGE_TYPES.includes(payload.type);\n}\nif (isSupportedMessage(msg)) worker.postMessage(msg);\nelse console.warn('Unsupported worker message:', msg.type);","typeGuard":"function isDagreWorkerMessage(data) {\n  return typeof data === 'object' && data !== null && typeof data.type === 'string' && data.type === 'dagre.layout';\n}","tryCatchPattern":"// Note: this throw happens inside the worker, not on the calling thread.\n// Listen for worker errors and mismatch replies instead of try/catching postMessage:\nworker.addEventListener('error', (e) => console.error('worker error:', e.message));\nworker.onmessage = (e) => {\n  if (e.data && e.data.type === 'error') console.error('layout failed:', e.data.message);\n};","preventionTips":["Centralize message type strings as shared constants (e.g. MSG_LAYOUT = 'dagre.layout') used by both main thread and worker instead of string literals.","Keep client and worker bundles versioned/updated together so the message protocol stays in sync.","Before posting, assert the payload shape: an object with a `type` field matching the worker's supported set.","Add a default-case reply (postMessage an error) in the worker so unknown types are observable from the main thread."],"tags":["web-worker","postmessage","message-protocol","dagre","dispatcher"],"backgroundTag":"worker-message-type-mismatch","analyzedSha":"d8a543f5f847ef596aa58858d6adcf5d75545f7f","analyzedAt":"2026-08-27T19:21:42.082Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}