Blog นี้ช้ากว่าชาวบ้านเลย เพราะจริงแล้ว n8n 1.106.3 เก่ามากเลยนะ และมีพวกช่องโหว่ร้ายแรงด้วย ปีนี้คนอื่นน่าจะย้ายไปพวก OpenClaw / nanoclaw แต่เพราะผมขี้เกียจ สั้นดีนะ จริงๆ ผมมี Custom n8n มันทำงานกับ Local LLM เพราะ Timeout ไว้ จริงๆ ไม่ได้เขียน Blog ไว้เลย เดี๋ยวในนี้และกัน
Custom n8n มันทำงานกับ Local LLM เพราะ Timeout
เทคนิคนี้ ผมได้จาก AI มันเหมือนกันนะ แล้วมาทำ Custom Image ใช้มา 7-8 เดือนและ
อันนี้มา Recap สรุป เพราะ 2.9.4 มันไม่ต้องใช้ท่านี้แล้ว
สิ่งที่มันทำ พยายาม Inject ไฟล์ Config ใหม่เข้าไปเป็น Global Config Inbound/Outbound ผ่านตัว setGlobalDispatcher ของ undici โดยมีการกำหนดค่า ตามนี้
// Preload patch for n8n: relax inbound server timeouts AND outbound fetch (undici) timeouts.
(function () {
const toNum = (v, d) => {
const n = Number(v);
return Number.isFinite(n) ? n : d;
};
// Inbound: Node HTTP(S) server timeouts (affects browser -> n8n)
const inboundRequestTimeout = toNum(process.env.N8N_HTTP_REQUEST_TIMEOUT, 0); // 0 = disable per-request timeout
const inboundHeadersTimeout = toNum(process.env.N8N_HTTP_HEADERS_TIMEOUT, 120_000); // must be > keepAlive
const inboundKeepAliveTimeout = toNum(process.env.N8N_HTTP_KEEPALIVE_TIMEOUT, 65_000);
function patchServer(modName) {
try {
const mod = require(modName);
if (!mod || typeof mod.createServer !== 'function') return;
const orig = mod.createServer;
mod.createServer = function patchedCreateServer(...args) {
const srv = orig.apply(this, args);
try {
srv.requestTimeout = inboundRequestTimeout;
// Ensure headersTimeout > keepAliveTimeout by at least 1000ms
srv.keepAliveTimeout = inboundKeepAliveTimeout;
srv.headersTimeout = Math.max(inboundHeadersTimeout, inboundKeepAliveTimeout + 1000);
console.log(
`[patch] ${modName} server timeouts: request=${srv.requestTimeout}ms, ` +
`headers=${srv.headersTimeout}ms, keepAlive=${srv.keepAliveTimeout}ms`
);
} catch (e) {
console.warn('[patch] failed to set server timeouts on', modName, e?.message || e);
}
return srv;
};
} catch (e) {
console.warn('[patch] failed to patch module', modName, e?.message || e);
}
}
patchServer('http');
patchServer('https');
// Outbound: undici (Node fetch) timeouts (affects n8n -> LLM/API)
// If your model/API takes >30s to send first byte (headers), default undici will throw "Headers Timeout Error".
try {
const { Agent, setGlobalDispatcher } = require('undici');
const headersTimeout = toNum(process.env.FETCH_HEADERS_TIMEOUT, 180_000); // 3 min for first byte/headers
const bodyTimeout = toNum(process.env.FETCH_BODY_TIMEOUT, 1_200_000); // 20 min for full body/stream
const connectTimeout = toNum(process.env.FETCH_CONNECT_TIMEOUT, 60_000); // 60s TCP/TLS connect
const keepAliveTimeout = toNum(process.env.FETCH_KEEPALIVE_TIMEOUT, 65_000);
const dispatcher = new Agent({
headersTimeout,
bodyTimeout,
connectTimeout,
keepAliveTimeout,
// keepAliveMaxTimeout can be set if your Node/undici version supports it; keep defaults otherwise.
});
setGlobalDispatcher(dispatcher);
console.log(
`[patch] undici dispatcher set: headersTimeout=${headersTimeout}ms, ` +
`bodyTimeout=${bodyTimeout}ms, connectTimeout=${connectTimeout}ms, ` +
`keepAliveTimeout=${keepAliveTimeout}ms`
);
} catch (e) {
console.warn('[patch] undici not available or failed to set dispatcher', e?.message || e);
}
})();ตอนแรกก็งง ว่า AI มันเอาอะไรมาให้ เลยลองๆหาข้อมูลมาอ่านเพิ่ม ตามนีครับ https://blog.platformatic.dev/http-fundamentals-understanding-undici-and-its-working-mechanism
แล้วที่นี่ส่วนของ Dockerfile เราจะ Custom n8n โดยทำ Dockerfile ประมาณนี้
FROM n8nio/n8n:latest ## 1.106.3
USER root
# Install undici into a known path and expose via NODE_PATH
RUN mkdir -p /opt/extra && \
npm --prefix /opt/extra install undici@5 && \
chown -R node:node /opt/extra
ENV NODE_PATH=/opt/extra/node_modules
USER nodeจากนั้นก็ Build
docker build -t pingkunga/n8n_llm_timeout:1.106.3 .
และก็กำหนด ENV เพิ่มใน docker compose เรา เห็นว่ามีเพิ่ม patch-http-timeouts.js
- NODE_OPTIONS=--require /path/to/your/mount/patch-http-timeouts.js
- N8N_HTTP_REQUEST_TIMEOUT=0 # 0 = disable per-request timeout
- N8N_HTTP_HEADERS_TIMEOUT=120000 # 2 minutes; must be > keep-alive
- N8N_HTTP_KEEPALIVE_TIMEOUT=65000 # 65 seconds
# Outbound fetch/undici timeouts
- FETCH_HEADERS_TIMEOUT=1800000 # time allowed to receive response headers
- FETCH_BODY_TIMEOUT=12000000 # total time allowed to receive the body/stream
- FETCH_CONNECT_TIMEOUT=600000 # total time for waiting for a connect
- FETCH_KEEPALIVE_TIMEOUT=65000Ref: https://github.com/n8n-io/n8n/issues/11886
n8n 1.106.3 > 2.9.4 มีอะไรเปลี่ยนแปลงบ้าง
🛡️ Security & Core
- Block environment variable access จาก Code Node - ถ้าใช่ต้องไปเปิดเอง
N8N_BLOCK_ENV_ACCESS_IN_NODE=false - ปิด Node สุ่มเสี่ยง:
Execute Command/Local File Trigger - Task Runners เปิดเป็นค่าเริ่มต้น พวก Node Code จะรันแยก ENV
- Enforce settings file permissions - 600 ให้ Owner อ่านอย่างเดียว
💾 Database
- Drop MySQL/MariaDB support >> ใช้ PostgreSQL หรือ SQLite (Pooled)
- Remove in-memory binary data mode >> กำหนดใหม่จาก
N8N_AVAILABLE_BINARY_DATA_MODESว่าเป็น filesystem / database / s3
⚙️ Workflow Building
- แยกระบบ Save กับ Publish
- Return expected sub-workflow data when the sub-workflow resumes from waiting (waiting for webhook, forms, HITL, etc.) - sub-workflow ถ้ามันติดอะไร เช่น รอคน Approve มันจะทำงานเพี้ยน ตอนนี้แก้แล้ว
- ยกเลิก
StartNode: ต้องใช้ Trigger Node เฉพาะทาง (เช่น Manual Trigger, Schedule, Webhook)
🤖 AI & New Features
- Human-in-the-Loop (HITL): Approve/Decline ก่อนที่ AI Agent จะทำงานต่อไปได้
- Time Saved Node: Node บอกประหยัดเวลาการทำงานคนไปได้เท่าไหร่ เพื่อใช้วัดผล ROI ของการทำ Automation
- AI Builder & Tools: ปรับปรุง UI การสร้าง AI Agent, การจัดการ Chat Memory และระบบ Embeddings ให้เสถียรและทำงานกับ Vector Database
ถ้าใครใช้ Node แปลกๆ ลองดูตัว https://docs.n8n.io/migration-tool-v2/ มันจะได้ตัวว่า WorkFlow ตัวไหนพัง ปรับอย่างไร ของผมมันท่ามาตรฐาน
แล้วเรื่อง Custom n8n มันทำงานกับ Local LLM เพราะ Timeout ไม่ต้องทำแล้วครับ เพราะ n8n ver ใหม่ๆ เพิ่ม ENV N8N_AI_TIMEOUT_MAX ของผมกำหนดไปเลบ 6000000 = 100 นาทีครับ คอมผมมันเก่า Dell Insirpon CPU Intel Gen 8 RAM 32GB งานเรารอได้ 555
จริงวันนี้อยู่มาขยับ Qwen3.5:9b มาแล้ว วันนี้เอ้าหละ ขยับเถอะ และก่อนขยับ n8n อย่าลืม Backup เดียวถ้าใช้ไปสัก 1-2 เดือน แล้วมันนิ่งๆ ต่อเอา docker compose แปะ blog
Reference
- https://docs.n8n.io/2-0-breaking-changes/#removed-nodes-for-retired-services
- https://linux.do/t/topic/1521148/6
Discover more from naiwaen@DebuggingSoft
Subscribe to get the latest posts sent to your email.



