Skip to content
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

Deprecate variadic listen method (closes #3652) #3712

Merged
merged 4 commits into from Mar 5, 2022
Merged

Deprecate variadic listen method (closes #3652) #3712

merged 4 commits into from Mar 5, 2022

Conversation

jsumners
Copy link
Member

@jsumners jsumners commented Feb 18, 2022

Resolves #3652.

As I am going through the process of getting this PR together, I am more convinced that this is the right path. I have had to jump through several hoops to cover cases of "was this signature provided? That one? This one?", and deal with adding/removing coverage from tests. Once we get past the deprecation phase, the listen code will be simplified by virtue of completely removing that normalizeListenArgs function and the ceremony around feeding it.

Technically, as implemented, the signature is still variadic since it accepts a second, optional, parameter for the callback. Should we require the callback in the options object? This would be slightly odd in that it isn't a typical pattern. But we already internally support (and actually require) listenOptions.cb be defined when a callback is to be used.

Checklist

@jsumners jsumners changed the base branch from next to main February 19, 2022 13:05
@jsumners jsumners added this to the v4.0.0 milestone Feb 21, 2022
@jsumners jsumners force-pushed the issue-3652 branch 3 times, most recently from 9770bbf to 5fab6f0 Compare February 22, 2022 01:35
@jsumners jsumners marked this pull request as ready for review February 24, 2022 17:48
@jsumners jsumners requested review from mcollina, delvedor, Fdawgs and a team February 24, 2022 17:48
@zekth
Copy link
Member

zekth commented Feb 25, 2022

Should we require the callback in the options object

On one hand it makes totally a good point to do it this way, on the other this is a slight change of common use from the javascript ecosystem; this will potentially raise Developer questions.

I'm +1 on this approach.

@mcollina
Copy link
Member

Regarding the callback: let's keep it as a separate argument.


I'm not really convinced that we ready for a deprecation cycle warning on this. I fear that the churn for our users and the uproar on our repo would be too high.

However I support the change to a single object everywhere including our docs.

How about:

  1. we stop using the variadic signature ourselves, including in our docs. Mark it as deprecated in docs and typescript.
  2. runtime deprecate it in v5
  3. remove in v6

Node has a --pending-deprecation, we might look into hooking into the same logic.

@jsumners
Copy link
Member Author

I fear that the churn for our users and the uproar on our repo would be too high.

Can't we make the same argument for every release?

  • runtime deprecate it in v5
  • remove in v6

Are we planning for a more aggressive release cycle? I think we should try to track core's LTS cycle.

Node has a --pending-deprecation,

This is the first I am learning about this flag. I bet not many outside of core know about it.

@mcollina
Copy link
Member

I would target a one-release-per-year cycle. v4 has been dragging way too long.

@jsumners
Copy link
Member Author

Agreed. That timeline matches with tracking core LTS. Which means we would end up maintaining this code block for two more years instead of one. What other churn in v4 are we saying will cause this one to be too much?

Copy link
Member

@Eomm Eomm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code: LGMT but this PR requires a follow-up PR for documentation.

I would release it in v4 after updating the docs as well.

@jsumners
Copy link
Member Author

What follow up for docs? All docs are updated in this PR.

Copy link
Member

@RafaelGSS RafaelGSS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Member

@RafaelGSS RafaelGSS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think is missing to update:

lib/server.js Outdated Show resolved Hide resolved
test/listen.deprecated.test.js Show resolved Hide resolved
@Eomm
Copy link
Member

Eomm commented Feb 28, 2022

What follow up for docs? All docs are updated in this PR.

I see only js and json files' changes.

I mean the README for example, that uses the .listen(3000) signature

@Eomm Eomm added v4.x Issue or pr related to Fastify v4 missing types PR that does not implement TypeScript changes labels Feb 28, 2022
@jsumners
Copy link
Member Author

I see only js and json files' changes.

I mean the README for example, that uses the .listen(3000) signature

A push got missed. Probably forgot to use --force. But I did miss the main Readme. So I'll have to fix that.

@jsumners jsumners force-pushed the issue-3652 branch 2 times, most recently from b617acb to 4d49ced Compare February 28, 2022 20:26
@jsumners
Copy link
Member Author

Readme and examples have been updated.

What other churn in v4 are we saying will cause this one to be too much?

@mcollina can you address this question?

@darkgl0w
Copy link
Member

darkgl0w commented Mar 3, 2022

Concerning the typescript definitions, the missing-types tag is not needed.
It is just a matter of adding a deprecated notice or this before lines 85, 86 and 87:

A PR targeting this one would be welcome. But I can say that the listenOptions object has more properties than I see in your comments.

After my zoom conference (it should end in less than one hour) I will submit one with all these options and a proper deprecation message ^^
Should I target main branch or directly this issue-3652 branch ?

@jsumners
Copy link
Member Author

jsumners commented Mar 3, 2022

Should I target main branch or directly this issue-3652 branch ?

It should target the branch of this PR.

@Eomm

This comment was marked as resolved.

@jsumners

This comment was marked as resolved.


```js
fastify.listen({ port: 3000, host: '127.0.0.1', backlog: 511 }, (err) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the backlog parameter?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifying it no longer matches with the lead-in text.

lib/warnings.js Outdated Show resolved Hide resolved
jsumners and others added 2 commits March 3, 2022 22:54
Co-authored-by: darkgl0w <31093081+darkgl0w@users.noreply.github.com>
@darkgl0w
Copy link
Member

darkgl0w commented Mar 4, 2022

The PR adding typescript definitions for this change is ready to be reviewed here.

While digging in the code to write the types a few points raised my attention :

  1. technically fastify.listen() is valid as it falls back to listening on localhost and the first random open port on both ipv4 and ipv6, but it currently displays the deprecation warning (this conditional case is not covered). Is it a wanted behavior ?

  2. same goes for the fastify.listen(() => {}) call that is technically valid (no options, just a callback), same question here.

  3. the state of the callback argument is not clear to me, at least in the discussions. Code wise the callback argument will trigger the deprecation warning. Should I mark all the types with a callback argument as deprecated (point 2 included)?

@jsumners
Copy link
Member Author

jsumners commented Mar 4, 2022

  1. technically fastify.listen() is valid as it falls back to listening on localhost and the first random open port on both ipv4 and ipv6, but it currently displays the deprecation warning (this conditional case is not covered). Is it a wanted behavior ?

No.

2. same goes for the fastify.listen(() => {}) call that is technically valid (no options, just a callback), same question here.

Same bug.

3. the state of the callback argument is not clear to me, at least in the discussions. Code wise the callback argument will trigger the deprecation warning. Should I mark all the types with a callback argument as deprecated (point 2 included)?

No.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm,

could you add this to the release notes (google docs) too?

@jsumners
Copy link
Member Author

jsumners commented Mar 5, 2022

@darkgl0w I have addressed the bugs you found.

@mcollina please forward that link to me again.

Copy link
Member

@delvedor delvedor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mcollina
Copy link
Member

mcollina commented Mar 5, 2022

@jsumners what link?

@jsumners
Copy link
Member Author

jsumners commented Mar 5, 2022

@jsumners what link?

The Google doc. @RafaelGSS got it to me.

@github-actions
Copy link

github-actions bot commented Mar 6, 2023

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
missing types PR that does not implement TypeScript changes v4.x Issue or pr related to Fastify v4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate variadic .listen signature
8 participants