question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix dynamic context callbacks sometimes returning null

See original GitHub issue

I 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 after map = require("lodash/map"), line
  • Update object.resolveDynamicContexts function’s return statement and wrap returning map function in filter() 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:closed
  • Created 4 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
max-tgamcommented, Sep 19, 2019

@colmsnowplow This is what I mentioned yesterday during the call.

0reactions
max-tgamcommented, Sep 30, 2019
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found