awesome-debounce-promise icon indicating copy to clipboard operation
awesome-debounce-promise copied to clipboard

Getting "null is not an object" sometimes

Open NOtherDev opened this issue 5 years ago • 9 comments
trafficstars

Unable to reproduce myself, but Bugsnag reports this error several times a day on production, in node_modules/debounce-promise/dist/index.js:54:141:

Promise.resolve(options.accumulate ? fn.call(this, pendingArgs) : fn.apply(this, pendingArgs[pendingArgs.length - 1])).then(thisDeferred.resolve, thisDeferred.reject);

I believe it's some kind of race condition when the deferred object was already cleared.

We use ADP in React component like this:

    fetch = async () => {
        this.setState({fetching: true}, () => {
                somethingAsync()
                    .then((data) => {
                        // setState(data)
                        this.debouncer = undefined
                    })
        })
    }

    debounce = () => {
        if (!this.debouncer) {
            this.debouncer = AwesomeDebouncePromise(this.fetch, 500)
        }
        this.debouncer()
    }

    someActionCalledFromMultiplePlaces = () => {    
        this.debounce()
    }

NOtherDev avatar Oct 21 '20 09:10 NOtherDev

Hi,

This will be hard for me to fix if it's not possible to reproduce unfortunately. Maybe it is affecting only a subset of your users and you have more context about the user environment (I mean, maybe it's only a specific version of a specific browser)

Sharing the full stacktrace, not just the error message, might be helpful as well.

slorber avatar Oct 23 '20 09:10 slorber

Yeah, I might imagine, sorry for that, I'd happily submit more if I only have it 🙂 It affects both Safari Mobile users as well as Chrome Desktop, so no clear env distinction here. No stack trace provided by Bugsnag 😞

NOtherDev avatar Oct 23 '20 10:10 NOtherDev

Maybe someone else will come up with more infos someday 😅

Could as well be a bug in https://github.com/bjoerge/debounce-promise, the underlying lib

Also sometimes bugs like that are triggered for weird reasons like browser plugins that affect the dom in a weird way.

slorber avatar Oct 23 '20 14:10 slorber

I have the same problem in a react native app: TypeError: Cannot read property 'resolve' of null stack: node_modules/debounce-promise/dist/index.js:54

It is reported on production every now and then but I was not able to reproduce it. Just to let you know.

maps82 avatar Nov 03 '20 10:11 maps82

thanks

what's your RN version and runtime? JSC (default), V8, Hermes? iOS/Android?

have you reported it to the original repo? as the error is thrown here?

slorber avatar Nov 03 '20 10:11 slorber

No, sorry I implemented the functionality with lodash's debounce function now.

maps82 avatar Nov 03 '20 19:11 maps82

React native is 0.63.3 with hermes js. Until now I just had the report on android devices, but our iOS release may have the same issue (iOS version is released since a few days only)

maps82 avatar Nov 03 '20 19:11 maps82

Thanks. Let me know if you have the problem on iOS as well, but it's likely to also be on iOS if @NOtherDev see it on Safari and Chrome.

slorber avatar Nov 04 '20 14:11 slorber

@bjoerge any idea? Has someone else reported the problem?

slorber avatar Nov 04 '20 14:11 slorber