{"record":{"id":"7d0b88d5071442e9","repo":"BabylonJS/Babylon.js","slug":"cannot-get-nan-of-a","errorCode":null,"errorMessage":"Cannot get NaN of ${a}","messagePattern":"Cannot get NaN of (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.pure.ts","lineNumber":858,"sourceCode":"\r\n    private _polymorphicGreaterThanOrEqual(a: FlowGraphNumber, b: FlowGraphNumber) {\r\n        return ComparisonOperators(a, b, (a, b) => a >= b);\r\n    }\r\n}\r\n\r\n/**\r\n * Is NaN block.\r\n */\r\nexport class FlowGraphIsNanBlock extends FlowGraphUnaryOperationBlock<FlowGraphNumber, boolean> {\r\n    constructor(config?: IFlowGraphBlockConfiguration) {\r\n        super(RichTypeAny, RichTypeBoolean, (a) => this._polymorphicIsNan(a), FlowGraphBlockNames.IsNaN, config);\r\n    }\r\n\r\n    private _polymorphicIsNan(a: FlowGraphNumber) {\r\n        if (isNumeric(a, true)) {\r\n            return isNaN(getNumericValue(a));\r\n        } else {\r\n            throw new Error(`Cannot get NaN of ${a}`);\r\n        }\r\n    }\r\n}\r\n\r\n/**\r\n * Is Inf block.\r\n */\r\nexport class FlowGraphIsInfinityBlock extends FlowGraphUnaryOperationBlock<FlowGraphNumber, boolean> {\r\n    constructor(config?: IFlowGraphBlockConfiguration) {\r\n        super(RichTypeAny, RichTypeBoolean, (a) => this._polymorphicIsInf(a), FlowGraphBlockNames.IsInfinity, config);\r\n    }\r\n\r\n    private _polymorphicIsInf(a: FlowGraphNumber) {\r\n        if (isNumeric(a)) {\r\n            return !isFinite(getNumericValue(a));\r\n        } else {\r\n            throw new Error(`Cannot get isInf of ${a}`);\r\n        }\r","sourceCodeStart":840,"sourceCodeEnd":876,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.pure.ts#L840-L876","documentation":"The IsNaN flow graph block calls _polymorphicIsNan, which uses isNumeric(a, true) — a variant that accepts numbers and FlowGraphInteger values only (the second argument is not the boolean-tolerant mode here). If the input is a boolean, string, vector, or other FlowGraphTypes value, the block throws instead of returning a result. NaN checks only make sense for numeric inputs, so non-numeric input is treated as an authoring error.","triggerScenarios":"Connecting a non-numeric connection (boolean, string, Vector2/3/4, Quaternion, FlowGraphInteger is OK) into the IsNaN block's input and executing the block.","commonSituations":"Using IsNaN to test whether an optional/undefined input 'is empty' — the wiring carries a wrong-typed default value; passing a boolean from a logic block into IsNaN; graph serialization assigning a string to the input.","solutions":["Feed the IsNaN block a numeric input only; if the value may be missing, provide a numeric default (e.g. 0) upstream before the block.","Replace the IsNaN block with a type/value check block appropriate to the actual data type being tested.","Inspect the connection in the flow graph editor and remove the wrong-typed wire feeding the block."],"exampleFix":"// before: boolean into IsNaN\nisNaNBlock.value.connect(logicBlock.output); // throws\n\n// after: numeric input\nisNaNBlock.value.connect(divideBlock.output); // number input is valid","handlingStrategy":"validation","validationCode":"// before IsNaN block runs\nfunction validIsNanInput(v) {\n  return typeof v === 'number' || (typeof v === 'object' && v !== null && 'value' in v);\n}\nif (!validIsNanInput(isNanInput)) throw new TypeError('IsNaN input must be a number or FlowGraphInteger');","typeGuard":"function isNumericValue(v): v is number | FlowGraphInteger {\n  return typeof v === 'number' || (typeof v === 'object' && v !== null && 'value' in v);\n}","tryCatchPattern":"try {\n  result = isNanBlock.evaluate(context);\n} catch (e) {\n  if (e.message.startsWith('Cannot get NaN of')) {\n    result = false; // or handle as 'input was not numeric'\n  } else { throw e; }\n}","preventionTips":["Give numeric inputs explicit numeric defaults so an 'empty' connection never carries a wrong type.","Use IsNaN only downstream of arithmetic blocks that provably output numbers.","Validate serialized graphs after load: check connection source types match target port expectations."],"tags":["babylonjs","flow-graph","isnan","type-mismatch"],"backgroundTag":"non-numeric-operand","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}