awesome-debounce-promise
awesome-debounce-promise copied to clipboard
Getting "null is not an object" sometimes
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()
}
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.
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 😞
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.
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.
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?
No, sorry I implemented the functionality with lodash's debounce function now.
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)
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.
@bjoerge any idea? Has someone else reported the problem?