-
-
Notifications
You must be signed in to change notification settings - Fork 23.3k
Description
Describe the bug
When using OpenAI models (gpt-4o-mini, gpt-3.5-turbo, gpt-4, etc.) in Condition Agent nodes, Flowise attempts to fetch tiktoken tokenizer data from tiktoken.pages.dev for pre-calculation of token counts. When this domain is unreachable due to network restrictions (DNS issues, firewalls, corporate proxies), the node hangs for 15+ seconds with multiple retry attempts before falling back to approximate counting.
This issue is specific to Condition Agent nodes only - regular Agent nodes, QnA nodes, and other specialist agents do not exhibit this behavior because they don't require pre-execution token counting.
Error logs:
flowise | Failed to calculate number of tokens, falling back to approximate count TypeError: fetch failed
flowise | at node:internal/deps/undici/undici:13510:13
flowise | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
flowise | at async RetryOperation._fn (/usr/local/lib/node_modules/flowise/node_modules/p-retry/index.js:50:12) {
flowise | [cause]: Error: getaddrinfo EAI_AGAIN tiktoken.pages.dev
flowise | at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:122:26) {
flowise | errno: -3001,
flowise | code: 'EAI_AGAIN',
flowise | syscall: 'getaddrinfo',
flowise | hostname: 'tiktoken.pages.dev'
flowise | }
flowise | }
Impact:
- Response times increase from 2-3 seconds to 15+ seconds
- Production deployments unusable in corporate/restricted networks
- Forced to use non-OpenAI models despite licensing/requirements
To Reproduce
- Deploy Flowise in an environment where
tiktoken.pages.devis unreachable (corporate network, firewall blocking Cloudflare Pages, DNS restrictions) - Create an agentflow with a Condition Agent node
- Configure the Condition Agent to use any OpenAI model (gpt-4o-mini, gpt-3.5-turbo, gpt-4)
- Send a message through the agentflow
- Observe logs showing repeated DNS failures to
tiktoken.pages.dev - Notice 15+ second delay before response is generated
Network diagnostics showing the issue:
# DNS resolution fails
$ docker compose exec flowise nslookup tiktoken.pages.dev
;; connection timed out; no servers could be reached
# But other domains work fine
$ docker compose exec flowise nslookup google.com
Name: google.com
Address: 142.251.140.46Important: The issue does NOT occur with:
- Google Gemini models (gemini-pro, gemini-2.5-flash) in Condition Agent
- OpenAI models in regular Agent nodes (non-condition)
- Other specialist agents (QnA, Database Query, etc.)
Expected behavior
Condition Agent nodes should handle tiktoken fetch failures gracefully:
- Fast timeout: Fail fast (1-2 seconds max) instead of hanging for 15+ seconds
- Immediate fallback: Switch to approximate token counting without blocking
- Configuration option: Provide environment variable to disable tiktoken fetching entirely:
DISABLE_TIKTOKEN=trueUSE_APPROXIMATE_TOKENS=trueTIKTOKEN_TIMEOUT=1000(milliseconds)
- Graceful degradation: Log warning but continue execution immediately
The node should function normally with approximate token counting when tiktoken is unavailable, similar to how it eventually behaves after the timeout.
Screenshots
flowise | Failed to calculate number of tokens, falling back to approximate count TypeError: fetch failed
flowise | at node:internal/deps/undici/undici:13510:13
flowise | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
flowise | at async RetryOperation._fn (/usr/local/lib/node_modules/flowise/node_modules/p-retry/index.js:50:12) {
flowise | [cause]: Error: getaddrinfo EAI_AGAIN tiktoken.pages.dev
flowise | at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:122:26) {
flowise | errno: -3001,
flowise | code: 'EAI_AGAIN',
flowise | syscall: 'getaddrinfo',
flowise | hostname: 'tiktoken.pages.dev'
flowise | }
flowise | }
flowise | Failed to calculate number of tokens, falling back to approximate count TypeError: fetch failed
flowise | at node:internal/deps/undici/undici:13510:13
flowise | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
flowise | at async RetryOperation._fn (/usr/local/lib/node_modules/flowise/node_modules/p-retry/index.js:50:12) {
flowise | [cause]: Error: getaddrinfo EAI_AGAIN tiktoken.pages.dev
flowise | at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:122:26) {
flowise | errno: -3001,
flowise | code: 'EAI_AGAIN',
flowise | syscall: 'getaddrinfo',
flowise | hostname: 'tiktoken.pages.dev'
flowise | }
flowise | }
Flow
Use Method
Docker
Flowise Version
3.0.11
Operating System
None
Browser
None
Additional context
No response