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

[express-serve-static-core]: (re)fix listen callback type (#35883)" #47063

Merged
merged 1 commit into from
Sep 1, 2020
Merged

[express-serve-static-core]: (re)fix listen callback type (#35883)" #47063

merged 1 commit into from
Sep 1, 2020

Conversation

davidlj95
Copy link
Contributor

@davidlj95 davidlj95 commented Aug 26, 2020

Description

TL;DR: This reverts commit 34f4572.

The listen callback arguments argument

In the mentioned commit, arguments to the callback function argument on the app.prototype.listen method were added. The app.prototype.listen, as the docs of express say, is passing arguments directly to Node.js http server .listen. But turns out that since the beginning of Node.js, that callback does not receive anything as arguments:

Then, in order to prevent devs think that they will receive arguments in that callback (like for instance an error object) when actually no arguments to that callback are sent, I think it should be better to remove those non existing arguments from the type definitions.

How to catch errors on listen

To catch errors raised on listening, as the docs say, you have to register a listener for the 'error' event in the created server

https://nodejs.org/api/net.html#net_server_listen

In that callback, you'll have the error object describing what happened as the argument

Discussion

More context:
34f4572

Credits

Thanks to @tsimbalar for raising this issue in a project which lead to this discovery

Checks

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: 34f4572
  • N/A If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.
  • Include tests for your changes
  • If you are making substantial changes, consider adding a tslint.json containing { "extends": "dtslint/dt.json" }. If for reason the any rule need to be disabled, disable it for that line using // tslint:disable-next-line [ruleName] and not for whole package so that the need for disabling can be reviewed.

This reverts commit 34f4572.

In that commit, arguments were added to the callback on the
`app.prototype.listen` method, which is the same as Node.js server one

As Node.js `.listen` callback is never called with arguments and to
avoid misleadings, arguments to that callback are removed from types as
the source code never emits a callback with arguments
@typescript-bot typescript-bot added this to Needs Author Action in New Pull Request Status Board Aug 26, 2020
@davidlj95 davidlj95 marked this pull request as ready for review August 26, 2020 23:26
davidlj95 referenced this pull request Aug 26, 2020
* [express-serve-static-core] Add tests

* [express-serve-static-core] listen's callback can take some parameters

* [express-serve-static-core] Add a definitions by section
@typescript-bot
Copy link
Contributor

typescript-bot commented Aug 26, 2020

@davidlj95 Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through.

This is a live comment which I will keep updated.

1 package in this PR

Code Reviews

Because you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ Most recent commit is approved by type definition owners or DT maintainers

All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 47063,
  "author": "davidlj95",
  "owners": [
    "borisyankov",
    "19majkel94",
    "kacepe",
    "micksatana",
    "samijaber",
    "aereal",
    "JoseLion",
    "dwrss",
    "andoshin11"
  ],
  "dangerLevel": "ScopedAndTested",
  "headCommitAbbrOid": "6d78fce",
  "headCommitOid": "6d78fceabe5187f3760933ca85fa6dfe165e49dc",
  "mergeIsRequested": true,
  "stalenessInDays": 0,
  "lastPushDate": "2020-08-26T23:26:20.000Z",
  "reopenedDate": "2020-08-26T23:26:14.000Z",
  "lastCommentDate": "2020-09-01T08:03:36.000Z",
  "maintainerBlessed": true,
  "reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/47063/files",
  "hasMergeConflict": false,
  "authorIsOwner": false,
  "isFirstContribution": true,
  "popularityLevel": "Critical",
  "newPackages": [],
  "packages": [
    "express-serve-static-core"
  ],
  "files": [
    {
      "path": "types/express-serve-static-core/express-serve-static-core-tests.ts",
      "kind": "test",
      "package": "express-serve-static-core"
    },
    {
      "path": "types/express-serve-static-core/index.d.ts",
      "kind": "definition",
      "package": "express-serve-static-core"
    }
  ],
  "hasDismissedReview": false,
  "ciResult": "pass",
  "lastReviewDate": "2020-09-01T07:58:17.000Z",
  "reviewersWithStaleReviews": [],
  "approvalFlags": 2,
  "isChangesRequested": false
}

@typescript-bot
Copy link
Contributor

🔔 @borisyankov @19majkel94 @kacepe @micksatana @samijaber @aereal @JoseLion @dwrss @andoshin11 — please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

@typescript-bot typescript-bot moved this from Needs Author Action to Needs Maintainer Review in New Pull Request Status Board Aug 26, 2020
@typescript-bot
Copy link
Contributor

👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings.

Let’s review the numbers, shall we?

Comparison details 📊
master #47063 diff
Batch compilation
Memory usage (MiB) 70.9 71.4 +0.7%
Type count 10128 10128 0%
Assignability cache size 1955 1955 0%
Language service
Samples taken 125 124 -1%
Identifiers in tests 125 124 -1%
getCompletionsAtPosition
    Mean duration (ms) 331.8 332.4 +0.2%
    Mean CV 10.4% 10.4%
    Worst duration (ms) 438.5 442.2 +0.9%
    Worst identifier send body
getQuickInfoAtPosition
    Mean duration (ms) 350.6 351.0 +0.1%
    Mean CV 11.2% 10.6% -4.5%
    Worst duration (ms) 464.0 459.3 -1.0%
    Worst identifier req res

It looks like nothing changed too much. I won’t post performance data again unless it gets worse.

@typescript-bot typescript-bot added the Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. label Aug 26, 2020
@elibarzilay elibarzilay moved this from Needs Maintainer Review to Waiting for Code Reviews in New Pull Request Status Board Aug 27, 2020
Copy link
Contributor

@dwrss dwrss left a comment

Choose a reason for hiding this comment

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

Not hugely fond of the breaking change, but this is a more accurate definition and having parameters that will never be passed could definitely mislead.

@typescript-bot typescript-bot added Owner Approved A listed owner of this package signed off on the pull request. Self Merge This PR can now be self-merged by the PR author or an owner labels Sep 1, 2020
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Waiting for Author to Merge in New Pull Request Status Board Sep 1, 2020
@typescript-bot
Copy link
Contributor

@davidlj95 Everything looks good here. Great job! I am ready to merge this PR on your behalf.

If you'd like that to happen, please post a comment saying:

Ready to merge

and I'll merge this PR almost instantly. Thanks for helping out! ❤️

(@borisyankov, @19majkel94, @kacepe, @micksatana, @samijaber, @aereal, @JoseLion, @dwrss, @andoshin11: you can do this too.)

@davidlj95
Copy link
Contributor Author

Ready to merge

@typescript-bot typescript-bot moved this from Waiting for Author to Merge to Recently Merged in New Pull Request Status Board Sep 1, 2020
@typescript-bot typescript-bot merged commit bb48ba4 into DefinitelyTyped:master Sep 1, 2020
@typescript-bot
Copy link
Contributor

I just published @types/express-serve-static-core@4.17.10 to npm.

@davidlj95 davidlj95 deleted the fix-express-listen-types branch September 1, 2020 08:16
chivesrs pushed a commit to chivesrs/DefinitelyTyped that referenced this pull request Sep 2, 2020
… listen callback type (DefinitelyTyped#35883)" by @davidlj95

This reverts commit 34f4572.

In that commit, arguments were added to the callback on the
`app.prototype.listen` method, which is the same as Node.js server one

As Node.js `.listen` callback is never called with arguments and to
avoid misleadings, arguments to that callback are removed from types as
the source code never emits a callback with arguments
@typescript-bot typescript-bot removed this from Recently Merged in New Pull Request Status Board Sep 2, 2020
joshbax189 added a commit to Meeco/js-sdk that referenced this pull request Sep 8, 2020
danielrearden pushed a commit to danielrearden/DefinitelyTyped that referenced this pull request Sep 22, 2020
… listen callback type (DefinitelyTyped#35883)" by @davidlj95

This reverts commit 34f4572.

In that commit, arguments were added to the callback on the
`app.prototype.listen` method, which is the same as Node.js server one

As Node.js `.listen` callback is never called with arguments and to
avoid misleadings, arguments to that callback are removed from types as
the source code never emits a callback with arguments
niik added a commit to desktop/desktop that referenced this pull request Nov 25, 2020
The error arg was bogus all along, see DefinitelyTyped/DefinitelyTyped#47063
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Critical package Owner Approved A listed owner of this package signed off on the pull request. Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. Self Merge This PR can now be self-merged by the PR author or an owner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants