I am experimenting with firebase-queue. I saw the option for sanitizing. It's described in the doc as
sanitize - specifies whether the data object passed to the processing function is sanitized of internal keys reserved for use by the queue. Defaults to true.
What does it mean?
I am getting an error for not specifying { sanitize : false }
When the
sanitize
option is set, the queue sanitizes (or cleans) the input provided to the processing function so that it resembles that which the original client placed onto the queue, and doesn't contain any of the keys added by the implementation of the queue itself.If, however, you rely on a key (usually the keys starting with an underscore, e.g.
_id
) that is added by the queue, and not the original client, you need to setsanitize: false
so those keys are returned to your function and they're notundefined
.You can clearly see the difference with a simple processing function that just performs a
console.log(data)
.A quick note about why these keys are removed by default: Reading or writing directly to the location (as it looks like you're perhaps doing, by passing
undefined
into the client SDKchild()
method instead ofdata._id
) is generally a bad idea from within the worker itself as writes performed directly are not guarded by the extensive transaction logic in the queue to prevent race conditions. If you can isolate the work to taking input from the provideddata
field, and returning outputs to theresolve()
function, you'll likely have a better time scaling up your queue.