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 set sanitize: false
so those keys are returned to your function and they're not undefined
.
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 SDK child()
method instead of data._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 provided data
field, and returning outputs to the resolve()
function, you'll likely have a better time scaling up your queue.