-
Notifications
You must be signed in to change notification settings - Fork 583
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(node/dgram): support dgram (udp) node module compat #2205
Conversation
@cjihrig can you take a look too? |
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.
Awesome work, lots of tests enabled! This looks mostly good to me, but I'll wait for review from @cjihrig before landing
@@ -38,11 +38,11 @@ export class HandleWrap extends AsyncWrap { | |||
} | |||
|
|||
ref() { | |||
notImplemented("HandleWrap.prototype.ref"); | |||
unreachable(); |
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.
Why are these unreachable?
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.
As far as can see currently these methods exist purely for defining an interface on classes rather than something that will ever be implemented in this compat layer - felt more accurate to fail with unreachable than not implemented.
Wonder whether they should be defined at all… or if we want them, make use of the inheritance better and not override in all of the other wraps. E.g.
// handle_wrap.ts
class HandleWrap {
handle!: Handle;
// ... other code
ref(): void {
this.handle?.ref()
}
unref(): void {
this.handle?.unref()
}
}
// tcp_wrap.ts, pipe_wrap.ts, udp_wrap.ts etc.
class X extends HandleWrap {
methodA() {
// ...some code
this.handle = listener;
}
// no need to override `ref()` and `unref()`
}
Or perhaps could just exist as:
ref!: () => void;
unref!: () => void;
If we keep with the overrides elsewhere handling these methods.
9eb7131
to
7b9d800
Compare
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.
LGTM, nice work!
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.
LGTM. Nice work!
@cjihrig Thanks for your review! |
Works towards denoland/deno#18324