Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Approaching the issues
Closes dapr/js-sdk#604
Root cause
I reviewed the code at this link and printed the
result
object if the Dapr Workflow function runs it. The output is as follows:Based on the MDN documentation, this doesn't seem like the correct way to check if an object is an
AsyncGenerator
.To properly check if
result
is anAsyncGenerator
, we should use:This approach is more reliable and aligns with the standard practices for identifying
AsyncGenerator
objects. Once this check is corrected, the workflow function should work as expected.My thought
I opted not to write a test for this change because the new method,
typeof result[Symbol.asyncIterator] === 'function'
, is more theoretically correct and robust than the previous string-based approach because:Symbol.asyncIterator
, which is the defining characteristic of an async generator. This ensures we are accurately identifying async generators.typeof
to check for the existence of the async iterator method aligns with the theoretical underpinnings of JavaScript, making the check more reliable and less prone to errors due to changes in object string representations.Given that the new implementation is a more theoretically correct and robust method for identifying async generators, I believe that writing a test for this specific change might not be necessary. The new method improves the accuracy and reliability of the check without introducing additional complexity or potential points of failure.
Additionally, the robustness of the new method implies that it inherently handles the scenarios we care about, reducing the need for extensive testing compared to the previous string-based approach.
Feel free to adjust any part of this if needed!