-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix send / remove timing bug in Dispatcher #6756
Conversation
Hi @uforic. Thanks for the contribution! It looks to me like the proposed change here, while it will silence the TypeError, isn't really addressing the root cause, which is that something is attempting to send a message to to the worker after I don't think it's related Can you dig a little more into why something is attempting to send even after |
Howdy @jfirebaugh , thanks for getting back to us. Apologies for the delayed response. We were able to get some more information on this one. Another raw stack with occasional function names coming through:
I dug into a couple frames, and got their line nos in GitHub: Bottom of stack: Line 82 in d3f8ffc
Next up:
Totally possible I'm misdiagnosing things, but it seems like the onload to getJSON is getting called after map.remove has been called, which is then triggering send action via loadTile. Let me know what you think! Perhaps those promises need to be cancellable? I notice that the return type of getJSON is never stored off anywhere. |
Here's another stacktrace from production that I painstakingly un-uglified: raw stacktrace:
un-uglified: mapbox-gl-js/src/util/dispatcher.js Line 58 in 6997943
mapbox-gl-js/src/source/vector_tile_source.js Line 111 in 6997943
mapbox-gl-js/src/source/source_cache.js Line 149 in c9c4f61
mapbox-gl-js/src/source/source_cache.js Line 641 in c9c4f61
mapbox-gl-js/src/source/source_cache.js Line 542 in c9c4f61
mapbox-gl-js/src/source/source_cache.js Line 488 in c9c4f61
mapbox-gl-js/src/source/source_cache.js Line 79 in c9c4f61
mapbox-gl-js/src/util/evented.js Line 115 in bac1f67
mapbox-gl-js/src/source/load_tilejson.js Line 28 in 03680eb
Line 86 in d3f8ffc
As @uforic says, it looks like the map sends an XHR before it is removed. But the xhr isn't aborted, and so when it completes, the callbacks try to update retained tiles on the map, causing the tile to be loaded, but there are no actors and so ultimately we see this exception. So either |
Thanks, that was perfect detail. I opened a PR that should fix this: #6826. |
Excellent, thanks for the fix @jfirebaugh! 🙇♂️ |
Awesome, thanks! |
Description
I believe there is a JavaScript worker timing bug in dispatcher.js. On our Flexport Sentry, we are seeing infrequent bugs like this:
Unable to get property 'send' of undefined or null reference
, with a fuller stack trace:The TypeError is occurring on this line here.
It appears that the way this error is getting caused is:
asyncAll(Dispatcher.send(payload...
.TypeError.
Open to suggestions on how to improve this PR. One thing I'm curious about is:
Is it possible for Dispatcher.remove() to be called, but an async process then tries to call Dispatcher.send()?
It's totally possible that this is somehow user error, and that the user is somehow dispatching an action after having called map.remove(), but looking through the code (especially the Dispatcher broadcast function earlier in the file), it seems like like the answer is "yes".
Another question: Does anyone depend on the actor ID being returned? Will -1 have any negative downstream impact?