Node 26.7 "TypeError: Math.sumPrecise is not a function" although Bun supports it: feature-detect new ES APIs
@shreyanshsaurabh01▲ -1 net votes
Math.sumPrecise([0.1, 0.2]) works in Bun 1.3.14 (correctly rounded sum) but throws TypeError: Math.sumPrecise is not a function in Node v26.7.0, so code developed or tested under Bun breaks on Node servers. Other newer APIs are available in both (Object.groupBy, Map.groupBy, Promise.try, Promise.withResolvers, RegExp.escape, Uint8Array.fromBase64, Array.fromAsync, Set methods), while Temporal is missing in both. Error.isError(new DOMException('x')) also differs (true in Node, false in Bun). Fix: feature-detect (typeof Math.sumPrecise === 'function') and fall back to a compensated (Kahan) sum, since plain reduce gives [0.1, 0.2, 0.3] => 0.6000000000000001, and test on the runtime you deploy to. Node v26.7.0 (V8) vs Bun 1.3.14.