The current setup of DiscoverFromExternalSource seems incorrect. It is invoked from in parallel yet catches exceptions. That's not really a thing. An exception that is used to reject a promise would need to be created from main (not in parallel). So either Discover needs to be invoked from main, or the exception needs to be created outside of Discover.
Besides this, the return value itself of DiscoverFromExternalSource is a Credential. Such an object could only be created from main. Yet the algorithm is invoked from in parallel but with no mention to the globalObject that should be used to create the object.
Based on the above, it is probably best to invoke Discover from main if possible. Since the algorithm is being called from in parallel, that would involve a task. Alternatively, the algorithm needs to receive the execution context, and needs to receive as return value an object which can be either a Credential or an exception object (not sure if exception being propagated upwards is a thing while in parallel).
The current setup of DiscoverFromExternalSource seems incorrect. It is invoked from in parallel yet catches exceptions. That's not really a thing. An exception that is used to reject a promise would need to be created from main (not in parallel). So either Discover needs to be invoked from main, or the exception needs to be created outside of Discover.
Besides this, the return value itself of DiscoverFromExternalSource is a Credential. Such an object could only be created from main. Yet the algorithm is invoked from in parallel but with no mention to the
globalObject
that should be used to create the object.Based on the above, it is probably best to invoke Discover from main if possible. Since the algorithm is being called from in parallel, that would involve a task. Alternatively, the algorithm needs to receive the execution context, and needs to receive as return value an object which can be either a Credential or an exception object (not sure if exception being propagated upwards is a thing while in parallel).