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

[core] Misc modules/* cleanup #22983

Merged
merged 4 commits into from
Oct 12, 2020
Merged

[core] Misc modules/* cleanup #22983

merged 4 commits into from
Oct 12, 2020

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Oct 11, 2020

  • remove unused files from modules/
  • convert async IIFE into promise chain (which is the common/documented pattern for async actions in effects)
  • Replace modules/log and modules/handlekillSignal with native methods
    Node provides native methods/syntax for these patterns. Similar to Misc review for benchmarks mnajdova/material-ui#9

@eps1lon eps1lon added the core Infrastructure work going on behind the scenes label Oct 11, 2020
@mui-pr-bot
Copy link

No bundle size changes comparing 5ec7555...a3a0b3d

Generated by 🚫 dangerJS against a3a0b3d

@eps1lon eps1lon marked this pull request as ready for review October 11, 2020 16:44
@@ -4,46 +4,38 @@ const http = require('http');
const path = require('path');
const express = require('express');
const expect = require('expect-puppeteer');
const { addTeardown, shutdown } = require('../../../../modules/handleKillSignals');
Copy link
Member

@oliviertassinari oliviertassinari Oct 11, 2020

Choose a reason for hiding this comment

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

Are you sure about the teardown logic? How do we guarantee that the browser is correctly closed when sending an interruption signal to the node process? (that the browser doesn't stay idle as a dead leaf)

Copy link
Member Author

Choose a reason for hiding this comment

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

How long does the script run for you?

Copy link
Member Author

Choose a reason for hiding this comment

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

Also: you kind of can't. Orphaned processes are hard problem so you would need to show me a concrete case where this is a problem. A general solution is too much work for a little helper script.

Copy link
Member

@oliviertassinari oliviertassinari Oct 11, 2020

Choose a reason for hiding this comment

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

6,021 ms. Yeah ok, I see your point. For context, the teardown logic was previously used in Docker node.js files. We were using it for our web Next.js instances, our API express instances, and our end-to-end tests in puppeteer. We had different teardown to run in different orders, close redis connection, close postgres connection, stop http server handler, etc. I guess its overkill here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Node changed a lot regarding async/await logic. I'm fairly certain it takes care of possible orphan processes (and likely always did): You don't need to manually listen for sigint since any spawned processes are closed when the node process terminates.

Copy link
Member

@oliviertassinari oliviertassinari Oct 12, 2020

Choose a reason for hiding this comment

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

Agree with that. Our main use case was more for graceful shutdown (stop the http server first, then close the other connections, like the database).

@eps1lon eps1lon merged commit 20f6450 into mui:next Oct 12, 2020
@eps1lon eps1lon deleted the core/modules-cleanup branch October 12, 2020 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants