Skip to content

Getting "null is not an object" sometimes #18

@NOtherDev

Description

@NOtherDev

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()
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions