filterTransaction on undefined transaction

Hey, I am receiving error reports where JS throws an error in the code of some plugins with a filterTransaction method such as this:

export let accessRightsPlugin = function(options) {
    return new Plugin({
        key,
        filterTransaction: (transaction, state) => {
            let remote = transaction.getMeta('remote')
            ...
       },
       ...
    })
}

JavaScript throws the error:

Uncaught TypeError: Cannot read property 'getMeta' of undefined

Which would mean that the transaction was undefined. The question is then why does filterTransaction get triggered on an undefined transaction? I have not been able to reproduce this myself, but I have received the same error report from several different users.

This is one of the first things that gets done with a newly dispatched transaction, so if something is dispatching a transaction and passing in undefined as the transaction, this is likely the error you’ll see. Looking at the stack trace is likely to help.

1 Like

Thanks, looking further down the stack trace, I found circumstances under which a non-existent could be dispatched. I have fixed that case and verified all other dispatch calls. This should at least fix some cases.