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

Update production best practices #1679

Open
wants to merge 8 commits into
base: gh-pages
Choose a base branch
from

Conversation

bjohansebas
Copy link
Member

Modernize this page by making the following changes:

  • Update broken links
  • Remove references to Upstart, as this service has been in maintenance mode for several years
  • Remove references to Strongloop, updating documentation with current tools

Copy link

netlify bot commented Nov 10, 2024

Deploy Preview for expressjscom-preview ready!

Name Link
🔨 Latest commit c7ec093
🔍 Latest deploy log https://app.netlify.com/sites/expressjscom-preview/deploys/6785545768c8140008ccdfc0
😎 Deploy Preview https://deploy-preview-1679--expressjscom-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@bjohansebas bjohansebas self-assigned this Nov 10, 2024
@bjohansebas bjohansebas force-pushed the update-performance-info branch from 4133f2f to 0b2aeca Compare November 13, 2024 23:12
@bjohansebas bjohansebas marked this pull request as ready for review November 20, 2024 01:25
@bjohansebas bjohansebas changed the title [WIP]: Update production best practices Update production best practices Nov 20, 2024
@bjohansebas bjohansebas requested review from a team and carlosstenzel November 20, 2024 01:26
Copy link
Member

@UlisesGascon UlisesGascon left a comment

Choose a reason for hiding this comment

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

I like the changes, but I think that we need to have a good agreement on this (cc: @expressjs/express-tc )

Copy link
Member

@wesleytodd wesleytodd left a comment

Choose a reason for hiding this comment

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

I think this is an improvement for sure. Great work @bjohansebas!

I think we probably need to re-think the role our docs play in the ecosystem. Best practices have evolved quite a bit since this was all written, and it will evolve again in the coming years. We probably don't want to be the source for too much content like this unless we are able to keep it updated.

That said, for now, I am very much in support of improving this type of doc so LGTM!


#### For debugging

If you're logging for purposes of debugging, then instead of using `console.log()`, use a special debugging module like [debug](https://www.npmjs.com/package/debug). This module enables you to use the DEBUG environment variable to control what debug messages are sent to `console.error()`, if any. To keep your app purely asynchronous, you'd still want to pipe `console.error()` to another program. But then, you're not really going to debug in production, are you?

#### For app activity

If you're logging app activity (for example, tracking traffic or API calls), instead of using `console.log()`, use a logging library like [Winston](https://www.npmjs.com/package/winston) or [Bunyan](https://www.npmjs.com/package/bunyan). For a detailed comparison of these two libraries, see the StrongLoop blog post [Comparing Winston and Bunyan Node.js Logging](https://strongloop.com/strongblog/compare-node-js-logging-winston-bunyan/).
If you're logging app activity (for example, tracking traffic or API calls), instead of using `console.log()`, use a logging library like [Winston](https://www.npmjs.com/package/winston) or [Pino](https://www.npmjs.com/package/pino). There are more packages with the same purpose, you can check the LogRocket blog post ['Comparing Node.js logging tools'](https://blog.logrocket.com/comparing-node-js-logging-tools/) for a comparison between these packages and others.
Copy link
Member

Choose a reason for hiding this comment

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

We should deprecate and remove all references to winston and bunyan. Pino is the only good recommendation these days.

Copy link
Member

Choose a reason for hiding this comment

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

Agree too

Copy link
Member Author

Choose a reason for hiding this comment

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

Should I also delete the blog post? I think it would be good to keep it.

@@ -142,26 +142,23 @@ Now, all errors asynchronous and synchronous get propagated to the error middlew

However, there are two caveats:

1. All your asynchronous code must return promises (except emitters). If a particular library does not return promises, convert the base object by using a helper function like [Bluebird.promisifyAll()](http://bluebirdjs.com/docs/api/promise.promisifyall.html).
1. All your asynchronous code must return promises (except emitters). If a particular library does not return promises, convert the base object by using a helper function like [util.promisify](https://nodejs.org/api/util.html#util_util_promisify_original).
Copy link
Member

Choose a reason for hiding this comment

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

This is pretty poorly worded imo, and frankly wrapping callback libraries in util.promisify is not best practice either. Additionally, since we added error handling support in v5 I wonder if we should remove or rewrite this section entirely?

Copy link
Member

Choose a reason for hiding this comment

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

Agree... seems like we can focus on v5 and remove this section

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll remove it, I'll open an issue to see if someone wants to make the change, or if not, I'll come back to it soon. I still need to think carefully about how to document it properly, and since my focus was on replacing links and updating some references in this PR, I don't want to delay it any further.

Copy link
Member

@wesleytodd wesleytodd left a comment

Choose a reason for hiding this comment

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

oops forgot to change it to approve

Copy link
Member

@ctcpip ctcpip left a comment

Choose a reason for hiding this comment

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

looks good. we should remove the link to forever though

en/advanced/best-practice-performance.md Outdated Show resolved Hide resolved
bjohansebas and others added 4 commits January 13, 2025 10:43
Co-authored-by: Chris de Almeida <ctcpip@users.noreply.github.com>
Co-authored-by: Chris de Almeida <ctcpip@users.noreply.github.com>
@bjohansebas bjohansebas requested a review from ctcpip January 13, 2025 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants