lobe-chat
lobe-chat copied to clipboard
[Bug] 知识库中上传大量文件导致页面崩溃
📦 部署环境
Docker
📦 部署模式
服务端模式(lobe-chat-database 镜像)
📌 软件版本
v1.62.7
💻 系统环境
Ubuntu
🌐 浏览器
Edge
🐛 问题描述
由于最近想做vscode插件开发,所以我就在知识库中上传了vscode-extension-samples这个仓库。在删除了一些没用的文件之后,上传的文件数量依旧近800个。但是上传过程中,不仅经常卡顿,而且时不时会出现页面崩溃,浏览器提示out of memory。
📷 复现步骤
docker-compose.yml如下:
services:
lobe-chat:
image: lobehub/lobe-chat-database
container_name: lobe-chat
ports:
- "3210:3210"
env_file:
- lobechat.env
networks:
- lobe
restart: always
networks:
lobe:
driver: bridge
enable_ipv6: true
ipam:
driver: default
lobechat.env文件如下:
# 网站域名
APP_URL=https://www.xxx.com:32100
KEY_VAULTS_SECRET='***'
DATABASE_URL=postgres://lobe-chat:******@www.xxx.com:5432/lobe-chat
S3_ACCESS_KEY_ID=***
S3_SECRET_ACCESS_KEY=***
# 用于 S3 API 访问的域名
S3_ENDPOINT=https://www.xxx.com:9000
S3_BUCKET=lobechat
# 用于外网访问 S3 的公共域名,需配置 CORS
S3_PUBLIC_DOMAIN=https://www.xxx.com:9000
S3_ENABLE_PATH_STYLE=1
S3_SET_ACL=0
#认证服务
CASDOOR_PORT=8000
NEXT_AUTH_SECRET=***
NEXT_AUTH_SSO_PROVIDERS=casdoor
NEXTAUTH_URL=https://www.xxx.com:32100/api/auth
AUTH_CASDOOR_ID=***
AUTH_CASDOOR_SECRET=***
AUTH_CASDOOR_ISSUER=https://auth.***.com:8000/
CASDOOR_WEBHOOK_SECRET=***
# 默认助手设置
DEFAULT_AGENT_CONFIG='model=deepseek-chat;provider=deepseek'
# 模型服务商设置
DEEPSEEK_API_KEY=***
OPENROUTER_API_KEY=***
SILICONCLOUD_API_KEY=***
OPENAI_API_KEY=***
OPENAI_PROXY_URL=https://openrouter.ai/api/v1
ZHIPU_API_KEY=***
# 向量化模型设置
DEFAULT_FILES_CONFIG=embedding_model=zhipu/embedding-3
nginx反代配置:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
map $remote_addr $proxy_forwarded_elem {
# IPv4 addresses can be sent as-is
~^[0-9.]+$ "for=$remote_addr";
# IPv6 addresses need to be bracketed and quoted
~^[0-9A-Fa-f:.]+$ "for=\"[$remote_addr]\"";
# Unix domain socket names cannot be represented in RFC 7239 syntax
default "for=unknown";
}
map $http_forwarded $proxy_add_forwarded {
# If the incoming Forwarded header is syntactically valid, append to it
"~^(,[ \\t]*)*([!#$%&'*+.^_`|~0-9A-Za-z-]+=([!#$%&'*+.^_`|~0-9A-Za-z-]+|\"([\\t \\x21\\x23-\\x5B\\x5D-\\x7E\\x80-\\xFF]|\\\\[\\t \\x21-\\x7E\\x80-\\xFF])*\"))?(;([!#$%&'*+.^_`|~0-9A-Za-z-]+=([!#$%&'*+.^_`|~0-9A-Za-z-]+|\"([\\t \\x21\\x23-\\x5B\\x5D-\\x7E\\x80-\\xFF]|\\\\[\\t \\x21-\\x7E\\x80-\\xFF])*\"))?)*([ \\t]*,([ \\t]*([!#$%&'*+.^_`|~0-9A-Za-z-]+=([!#$%&'*+.^_`|~0-9A-Za-z-]+|\"([\\t \\x21\\x23-\\x5B\\x5D-\\x7E\\x80-\\xFF]|\\\\[\\t \\x21-\\x7E\\x80-\\xFF])*\"))?(;([!#$%&'*+.^_`|~0-9A-Za-z-]+=([!#$%&'*+.^_`|~0-9A-Za-z-]+|\"([\\t \\x21\\x23-\\x5B\\x5D-\\x7E\\x80-\\xFF]|\\\\[\\t \\x21-\\x7E\\x80-\\xFF])*\"))?)*)?)*$" "$http_forwarded, $proxy_forwarded_elem";
# Otherwise, replace it
default "$proxy_forwarded_elem";
}
server {
listen 32100 ssl;
listen [::]:32100 ssl;
server_name www.xxx.com;
ssl_certificate /etc/nginx/sec/fullchain.pem;
ssl_certificate_key /etc/nginx/sec/privkey.pem;
if ($host != $server_name) {
return 404;
}
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
client_max_body_size 1000m;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Forwarded $proxy_add_forwarded;
proxy_cache off;# 关闭缓存
proxy_buffering off;# 关闭代理缓冲
chunked_transfer_encoding on;# 开启分块传输编码
tcp_nopush on;# 开启TCP NOPUSH选项,禁止Nagle算法
tcp_nodelay on;# 开启TCP NODELAY选项,禁止延迟ACK算法
keepalive_timeout 300;# 设定keep-alive超时时间为65秒
proxy_pass http://127.0.0.1:3210/;
}
}
Windows中克隆vscode-extension-examples仓库,使用 del /s
命令 删除 .git文件夹、.gitignore、所有gif/jpg/jpeg/png等无关文件后,整个文件夹大约还有3MB的大小。此时上传这个文件夹,等待几分钟,就有可能出现页面崩溃
🚦 期望结果
上传大量文件时,页面不应该崩溃
📝 补充信息
我使用了自部署的minio作为文件存储服务,上传少量文件时没出现过什么问题,上传200个文件也没出现崩溃