read ETIMEDOUT at TCP.onStreamRead (node:internal/stream_base_commons:217:20) #2504
Replies: 3 comments
-
Hi @hoanghiep1x0 From logs and (plugins/mongoose.ts) and the description, it seems that this issue is because of MongoDB connection timeout, maybe you can try without initializing mongo connection to see if it still happens? From some closed issues I found |
Beta Was this translation helpful? Give feedback.
-
Here's the Mongo plugin file I've modified. import mongoose from 'mongoose';
import { initializeModels } from '../models';
export default defineNitroPlugin(async (nitroApp) => {
try {
const config = useRuntimeConfig();
// useRuntimeConfig().mongoose.uri;
await mongoose.connect(config.mongoose.uri, {
socketTimeoutMS: 0,
connectTimeoutMS: 10000,
})
console.log("connect mongoodb");
// register all models
await initializeModels();
} catch (error) {
console.log(error);
throw createError({ status: 500, statusMessage: "Error connect database.", message: "Error connect database." });
}
mongoose.connection.on('disconnected', () => {
console.log('MongoDB disconnected');
});
mongoose.connection.on('error', err => {
console.error('MongoDB connection error:', err);
});
}) The output logs don't seem to indicate an issue with MongoDB. admin@Admins-MacBook-Pro news % npm run dev
dev
nuxt dev --inspect
Nuxt 3.11.2 with Nitro 2.9.6 6:38:57 PM
6:38:58 PM
➜ Local: http://localhost:3000/
➜ Network: use --host to expose
Debugger listening on ws://127.0.0.1:9229/fd022d1e-e7f5-49cb-81a5-7740f977dcb4
For help, see: https://nodejs.org/en/docs/inspector
ℹ Using default Tailwind CSS file nuxt:tailwindcss 6:39:05 PM
➜ DevTools: press Shift + Option + D in the browser (v1.3.2) 6:39:11 PM
ℹ Tailwind Viewer: http://localhost:3000/_tailwind/ nuxt:tailwindcss 6:39:13 PM
ℹ Vite client warmed up in 22772ms 6:39:38 PM
ℹ Vite server warmed up in 24957ms 6:39:41 PM
✔ Nuxt Nitro server built in 10682 ms
✔ Nuxt Nitro server built in 1644 ms nitro 6:46:10 PM
✔ Nuxt Nitro server built in 945 ms nitro 6:46:11 PM
connect mongoodb
All models initialized successfully
error====> read ETIMEDOUT
at TCP.onStreamRead (node:internal/stream_base_commons:217:20)
at TCP.callbackTrampoline (node:internal/async_hooks:130:17)
error====> read ETIMEDOUT
at TCP.onStreamRead (node:internal/stream_base_commons:217:20)
at TCP.callbackTrampoline (node:internal/async_hooks:130:17) Here's the code for handling errors when a client sends a request and encounters an error. export default defineNitroPlugin(async (nitroApp) => {
nitroApp.hooks.hook("error", (error) => {
console.log("error====>", error);
});
}) If there's no new request coming to the server, there won't be any errors. |
Beta Was this translation helpful? Give feedback.
-
[ioredis] Unhandled error event: Error: read ETIMEDOUT |
Beta Was this translation helpful? Give feedback.
-
Environment
Reproduction
https://stackblitz.com/~/github.com/hoanghiep1x0/nitro-clone
Describe the bug
My project is currently running normally, but every 5 or 15 minutes without any interaction from the client, I encounter the error read ETIMEDOUT at TCP.onStreamRead (node:internal/stream_base_commons:217:20). This is exactly like the issue described in this GitHub issue. How can I fix it?
Additional context
I'm running a project with Nuxt and trying to replicate the issue regarding write pipe and read ETIMEDOUT, seemingly originating from Nitro.
project nuxt : https://stackblitz.com/~/github.com/hoanghiep1x0/nuxt3-project
project nitro : https://stackblitz.com/~/github.com/hoanghiep1x0/nitro-clone
My project is functioning normally, but every 5 or 15 minutes without any client interaction, I encounter the read ETIMEDOUT error when sending requests using $fetch or useFetch in Nuxt. How can I address this issue?
Logs
Beta Was this translation helpful? Give feedback.
All reactions