Repository navigation
Fix filter node blocking every Date payload - #5990
Conversation
compareObjects treated any two Date objects as equal because a Date has no own enumerable keys. This made the filter (rbe) node block every Date payload, including the first one.
|
|
|
Looks good to me. But again will leave final decision to @knolleary as it is potentially breaking even though IMHO it is an improvement and is a fix. |
|
Thanks! On the breaking side: before this, the filter node passed the first Date and then blocked every Date after it, whatever the value. Two Dates with the same time are still treated as equal, so a flow that resends the same timestamp still gets filtered. |
|
Yes - I agree, but in theory some people may have some really obscure use case where they stumbled across that behaviour and rely on it... (or didn't realise it was happening but still rely on it). But yes I agree that the point of the node is pass through objects with properties that change value so it's a fix to me. |
Proposed changes
Fixes #5987
util.compareObjectstreated any two Date objects as equal, because a Date has no own enumerable keys and fell through to the plain object branch. So the filter node in "block unless value changes" mode blocked every Date payload after the first.This adds a Date check next to the existing Buffer check and compares them with
getTime(). A Date compared with a non-Date is not equal. Two Dates with the same time are still equal.Tests: one case in
util_spec.jsfor compareObjects, and one inrbe_spec.jsthat sends the same Date twice and then a new one, and checks that only the first and the new one pass. Both fail without the change.Checklist
npm run testto verify the unit tests pass