Skip to content

Commit a742050

Browse files
committed
🔧 Fix React Scripts devServer.close compatibility with Node.js v20+
1 parent 97c2c5a commit a742050

3 files changed

Lines changed: 245 additions & 1 deletion

File tree

client/package-lock.json

Lines changed: 195 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"lint:fix": "eslint src --ext .js,.jsx --fix",
2121
"format": "prettier --write src/",
2222
"format:check": "prettier --check src/",
23-
"code:fix": "npm run lint:fix && npm run format"
23+
"code:fix": "npm run lint:fix && npm run format",
24+
"postinstall": "patch-package"
2425
},
2526
"browserslist": {
2627
"production": [
@@ -49,6 +50,7 @@
4950
"eslint-plugin-prettier": "^5.5.1",
5051
"eslint-plugin-react": "^7.37.5",
5152
"eslint-plugin-react-hooks": "^5.2.0",
53+
"patch-package": "^8.0.0",
5254
"prettier": "^3.6.2",
5355
"react-app-rewired": "^2.2.1"
5456
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
diff --git a/node_modules/react-scripts/scripts/start.js b/node_modules/react-scripts/scripts/start.js
2+
index 8b9a2c2..c1c4637 100644
3+
--- a/node_modules/react-scripts/scripts/start.js
4+
+++ b/node_modules/react-scripts/scripts/start.js
5+
@@ -141,16 +141,38 @@ checkBrowsers(paths.appPath, isInteractive)
6+
7+
['SIGINT', 'SIGTERM'].forEach(function (sig) {
8+
process.on(sig, function () {
9+
- devServer.close();
10+
- process.exit();
11+
+ if (devServer.close && typeof devServer.close === 'function') {
12+
+ devServer.close(() => {
13+
+ process.exit();
14+
+ });
15+
+ } else if (devServer.stop && typeof devServer.stop === 'function') {
16+
+ devServer.stop().then(() => {
17+
+ process.exit();
18+
+ }).catch(() => {
19+
+ process.exit();
20+
+ });
21+
+ } else {
22+
+ process.exit();
23+
+ }
24+
});
25+
});
26+
27+
if (process.env.CI !== 'true') {
28+
// Gracefully exit when stdin ends
29+
process.stdin.on('end', function () {
30+
- devServer.close();
31+
- process.exit();
32+
+ if (devServer.close && typeof devServer.close === 'function') {
33+
+ devServer.close(() => {
34+
+ process.exit();
35+
+ });
36+
+ } else if (devServer.stop && typeof devServer.stop === 'function') {
37+
+ devServer.stop().then(() => {
38+
+ process.exit();
39+
+ }).catch(() => {
40+
+ process.exit();
41+
+ });
42+
+ } else {
43+
+ process.exit();
44+
+ }
45+
});
46+
}
47+
})

0 commit comments

Comments
 (0)