Fix dynamic context callbacks sometimes returning null
See original GitHub issueI have noticed that in some cases result of user supplied function for custom context or custom context itself can be set to null
instead of proper object. Since presence of one custom custom context not generally critical to event data - the data should not go into bad stream because logic sees null
instead of context.
The solution is to sanitize user supplied contexts for “falsy” values.
In order to do that the following adjustments would be needed in helpers.js
under src/js/lib
sub-folder add following:
filter = require("lodash/filter"),
line right aftermap = require("lodash/map"),
line- Update
object.resolveDynamicContexts
function’s return statement and wrap returningmap
function infilter()
i.e to this:
return filter(map(dynamicOrStaticContexts, function(context) {
if (typeof context === 'function') {
try {
return context.apply(null, params);
} catch (e) {
//TODO: provide warning
}
} else {
return context;
}
}));
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
How can class.this in a callback can be null? - java
In your case you are getting null because, by the time you call FragmentClass.this.getActivity(), your fragment is no longer visible to the user ......
Read more >Understanding the Event Loop, Callbacks, Promises, and ...
To do this, you will first learn about the original way to ensure asynchronous code is handled correctly by the event loop: callback...
Read more >The 10 Most Common JavaScript Issues Developers Face
If you need help figuring out why your JavaScript isn't working, consult this list of the 10 most common JavaScript issues from a...
Read more >Why is my currentUser == null in Firebase Auth? - Medium
The problem here is still that the user object delivered to the callback function is still either null or non-null.
Read more >An Essential Guide to JavaScript null
If you find a variable or a function that returns null , it means that the expected object couldn't be created. The following...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@colmsnowplow This is what I mentioned yesterday during the call.
@szareiangm FYI