Your function decodeWebStream
mutates the input variable d. This probably combined with an error elsewhere in your code double-encoding your data is probably leading to the second call of decodeWebStream
giving you the correct value (but not first or third).
1
solved Node.js bug ? function’s return value change when stored as variable