I’m facing a problem when trying to start my application using Vite and React, published through Jenkins and monitored by Grafana. The EPIPE error occurs repeatedly, and the application constantly tries to restart without success. Here are the details of the error and my project settings:
2024-07-19 22:45:57.660 error Command failed with exit code 1.
2024-07-19 22:45:57.371 ERROR run failed: command exited (1)
2024-07-19 22:45:57.370 vite.start: command (/app/) /tmp/yarn--1721439926269-0.49852721492640595/yarn run vite.start exited (1)
2024-07-19 22:45:57.370 vite.start: ERROR: command finished with error: command (/app/) /tmp/yarn--1721439926269-0.49852721492640595/yarn run vite.start exited (1)
2024-07-19 22:45:57.660 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2024-07-19 22:45:57.371
2024-07-19 22:45:57.371 Failed: //#vite.start
2024-07-19 22:45:57.371 Time: 26.507s
2024-07-19 22:45:57.371 Cached: 0 cached, 1 total
2024-07-19 22:45:57.371 Tasks: 0 successful, 1 total
2024-07-19 22:45:57.371
2024-07-19 22:45:57.057 vite.start: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2024-07-19 22:45:57.057 vite.start: error Command failed with exit code 1.
2024-07-19 22:45:56.957 vite.start: reject(new Error(error2));
2024-07-19 22:45:56.957 vite.start: at responseCallbacks.<computed> (/app/node_modules/esbuild/lib/main.js:622:9)
2024-07-19 22:45:56.957 vite.start: /app/node_modules/esbuild/lib/main.js:993
2024-07-19 22:45:56.957 vite.start: Error: The service was stopped: write EPIPE
2024-07-19 22:45:56.957 vite.start: ^
2024-07-19 22:45:56.957 vite.start: at process.processTicksAndRejections (node:internal/process/task_queues:84:21)
2024-07-19 22:45:56.957 vite.start:
2024-07-19 22:45:56.957 vite.start: at /app/node_modules/esbuild/lib/main.js:1983:18
2024-07-19 22:45:56.957 vite.start: at /app/node_modules/esbuild/lib/main.js:993:26
2024-07-19 22:45:56.957 vite.start: at afterClose (/app/node_modules/esbuild/lib/main.js:613:28)
2024-07-19 22:45:56.957 vite.start: Node.js v18.20.4
2024-07-19 22:45:56.957 vite.start: at onwriteError (node:internal/streams/writable:418:3)
2024-07-19 22:45:39.954 vite.start: Server running on port: 4173
2024-07-19 22:45:33.458 vite.start: $ node server.js
vite.config.ts:
export default defineConfig({
server: {
watch: {
usePolling: true,
},
port: 4173,
hmr: {
clientPort: 4173,
},
host: true,
strictPort: true,
},
base: './',
plugins: [react(), tsPaths()],
build: {
emptyOutDir: true,
cssMinify: 'lightningcss',
target: browserslistToEsbuild(),
rollupOptions: {
output: {
chunkFileNames: 'js/[name].[hash].js',
entryFileNames: 'js/[name].[hash].js',
assetFileNames: 'assets/[name].[hash].[ext]',
manualChunks: {
'react-vendor': ['react', 'react-dom', 'react-router-dom'],
},
},
},
},
optimizeDeps: {
include: ['react/jsx-runtime'],
},
})
turbo.json:
{
"$schema": "https://turbo.build/schema.json",
"tasks": {
"build": {
"outputs": [
"dist/**"
]
},
"lint": {}
}
}
server.js:
async function startServer() {
const vite = await createServer({
server: { middlewareMode: 'ssr' },
})
app.use(vite.middlewares)
app.get('/health-status', (req, res) => {
res.status(200).send('OK')
})
app.listen(port, '0.0.0.0', () => {
console.log(`Server running on port: ${port}`)
})
}
startServer()
package.json version
"react": "18.3.1",
"react-dom": "18.3.1",
"react-router-dom": "6.25.0",
"turbo": "2.0.7",
"typescript": "5.5.3",
"vite": "5.3.4",