greptile 2.2.9 → 2.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/health-server.js +16 -7
- package/package.json +1 -1
package/health-server.js
CHANGED
|
@@ -56,12 +56,18 @@ function checkForUpdate() {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
const req = https.get('https://registry.npmjs.org/greptile/latest', { timeout: 10_000 }, (res) => {
|
|
59
|
-
if (res.statusCode !== 200) {
|
|
59
|
+
if (res.statusCode !== 200) {
|
|
60
|
+
res.resume()
|
|
61
|
+
return
|
|
62
|
+
}
|
|
60
63
|
let data = ''
|
|
61
64
|
const MAX_BODY = 100_000 // 100KB safety limit
|
|
62
65
|
res.on('data', (chunk) => {
|
|
63
66
|
data += chunk
|
|
64
|
-
if (data.length > MAX_BODY) {
|
|
67
|
+
if (data.length > MAX_BODY) {
|
|
68
|
+
req.destroy()
|
|
69
|
+
return
|
|
70
|
+
}
|
|
65
71
|
})
|
|
66
72
|
res.on('end', () => {
|
|
67
73
|
try {
|
|
@@ -72,20 +78,21 @@ function checkForUpdate() {
|
|
|
72
78
|
const npmPaths = ['/opt/homebrew/bin/npm', '/usr/local/bin/npm']
|
|
73
79
|
let npmBin = 'npm'
|
|
74
80
|
for (const p of npmPaths) {
|
|
75
|
-
if (fs.existsSync(p)) {
|
|
81
|
+
if (fs.existsSync(p)) {
|
|
82
|
+
npmBin = p
|
|
83
|
+
break
|
|
84
|
+
}
|
|
76
85
|
}
|
|
77
86
|
let child
|
|
78
87
|
try {
|
|
79
88
|
child = spawn(npmBin, ['install', '-g', 'greptile@latest'], {
|
|
80
|
-
stdio: '
|
|
81
|
-
detached: true,
|
|
89
|
+
stdio: 'inherit',
|
|
82
90
|
})
|
|
83
91
|
} catch (err) {
|
|
84
92
|
console.error('Failed to spawn npm:', err.message)
|
|
85
93
|
return
|
|
86
94
|
}
|
|
87
95
|
isUpdating = true
|
|
88
|
-
child.unref()
|
|
89
96
|
child.on('close', (code) => {
|
|
90
97
|
isUpdating = false
|
|
91
98
|
if (code === 0) {
|
|
@@ -105,7 +112,9 @@ function checkForUpdate() {
|
|
|
105
112
|
})
|
|
106
113
|
})
|
|
107
114
|
req.on('error', () => {}) // Silently ignore network errors
|
|
108
|
-
req.on('timeout', () => {
|
|
115
|
+
req.on('timeout', () => {
|
|
116
|
+
req.destroy()
|
|
117
|
+
})
|
|
109
118
|
}
|
|
110
119
|
|
|
111
120
|
const ALLOWED_ORIGINS = ['https://app.greptile.com', 'https://app.staging.greptile.com', 'http://localhost:3000']
|