-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
feat(core,websockets): use rxjs to check if values are observables #9491
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pull Request Test Coverage Report for Build dcbc02b5-7264-47ae-ad61-0d9f89c128bd
💛 - Coveralls |
looks like the CI pipeline is broken 🤔 |
micalevisk
force-pushed
the
fix-use-isObservable
branch
2 times, most recently
from
April 23, 2022 02:41
98406df
to
88575ee
Compare
micalevisk
commented
Apr 23, 2022
@@ -158,7 +163,7 @@ export class WebSocketsController { | |||
deferredResult: Promise<any>, | |||
): Promise<Observable<any>> { | |||
const result = await deferredResult; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw the tests didn't cover the following
because
await Promise.resolve( Promise.resolve(123) )
return 123
(node16)
Should we drop that if?
micalevisk
force-pushed
the
fix-use-isObservable
branch
from
April 24, 2022 19:48
88575ee
to
bc0a1de
Compare
BrunnerLivio
approved these changes
Apr 26, 2022
12 tasks
micalevisk
changed the title
Use rxjs when checking if the value is an observable
feat: use rxjs to check if values are observables
May 25, 2022
micalevisk
changed the title
feat: use rxjs to check if values are observables
feat(core,websockets): use rxjs to check if values are observables
May 25, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Here's the full code: https://gitlab.com/micalevisk/nestjs-observable-issue
If we return a literal object that has the
subscribe
method on it, the application gets stuckIf we return
req.route
(from Express), we got the following error (and500
as a response)What is the new behavior?
Instead of checking if the return of the method has the function
subscribe
, we're usingisObservable
fromrxjs
to check if the return is, in fact, a valid observable objectThus, now with the above code the server will reply with this JSON instead:
as expected.
And just
{}
when we return{ subscribe(){} }
Does this PR introduce a breaking change?
Other information
There are other places in which
isObservable
is used. See:While others are using
isFunction(value.subscribe)
and I'm unsure if this was intentional. See:Should we do the same for
nest/packages/microservices/client/client-grpc.ts
Lines 211 to 212 in d9d628d
nest/packages/microservices/client/client-grpc.ts
Lines 154 to 155 in d9d628d
?