TypeError: Right-hand side of 'instanceof' is not callable in is-binary.js node 20+ sails-hook-sockets
Summary When running a project on Node.js 24, the application crashes with a TypeError during binary data checks in socket.io-parser. This happens because the check for withNativeFile (and potentially withNativeBlob) assumes that if the global exists, it is a valid constructor. If these globals are set to undefined (common in some legacy compatibility layers or strict environment sanitization), the instanceof check fails.
...\node_modules\socket.io-parser\build\cjs\is-binary.js:26 (withNativeFile && obj instanceof File)); ^
TypeError: Right-hand side of 'instanceof' is not callable at isBinary (...\node_modules\socket.io-parser\build\cjs\is-binary.js:26:32)
Suggested Fix Update the is-binary logic to verify the type of the constructor before performing the instanceof check:
function isBinary(obj) { return ( (withNativeArrayBuffer && typeof ArrayBuffer === 'function' && (obj instanceof ArrayBuffer || isView(obj))) || (withNativeBlob && typeof Blob === 'function' && obj instanceof Blob ) || (withNativeFile && typeof File === 'function' && obj instanceof File) ); }
Source: balderdashy/sails