Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker v1.51.4+ 页面静态化问题反馈(NextAuth 登录、FEATURE_FLAGS 、请求500 报错等) #5804

Closed
arvinxx opened this issue Feb 6, 2025 · 124 comments
Labels
⚡️ Performance Performance issue | 性能问题

Comments

@arvinxx
Copy link
Contributor

arvinxx commented Feb 6, 2025

背景

基于 RFC #5461 ,我们在 1.51.4 版本实现了页面路由的静态化,这个版本更新带来的好处是首屏页面加载能进入 1s 内,二次进入能做到百毫秒级别,进而实现页面的秒开体验。

但由于在这个版本我们尝试了一种新的路由架构来支持 RFC 中提到的效果,因此可能存在一些问题需要实践检验。目前已知的问题有:

环境变量(FEATURE_FLAG、MODEL_LIST) 失效(1.51.13 修复):

NextAuth 集成失效(1.51.13 修复):

/ 频繁报错,无法跳转登陆页(1.51.15 修复)

/discover/assistant/[id] 500 (1.51.6 修复)

/settings/provider/[id] 500 (1.51.10 修复)

/file/[id] 500 (1.51.11 修复)

如果大家还遇到其他问题,欢迎在下面留言补充,我争取第一时间修复。

针对上述问题,临时解法是锁定到 v1.51.3 版本,等我把几个核心问题修复后再升级上来。

目前可以尝试 1.52.0 版本


问题合集:

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


background

Based on RFC #5461, we implemented the static page routing in version 1.51.4. The benefit of this version update is that the homepage can be loaded within 1s. , the secondary entry can reach the level of 300~500ms, thereby realizing the instant opening experience of the page.

But in this version, we tried a new routing architecture to support the effects mentioned in RFC, so there may be some problems that need to be tested in practice. Currently known problems are:

FEATURE_FLAG is invalid (most likely, the RSC parameters cannot be transmitted through after the page is static, and are trying to fix it):

next_auth integration failed (the reason is currently unknown, under research):

If you encounter other problems, please leave a message below to add, and I will try to fix it as soon as possible.

In response to the above problems, the temporary solution is to lock the v1.51.3 version, and I will upgrade it after I fix several core problems.

@arvinxx arvinxx changed the title Docker v1.51.4+ 问题反馈( NextAuth 登录) Docker v1.51.4+ 页面静态化问题反馈(NextAuth 登录、FEATURE_FLAGS 等) Feb 6, 2025
@arvinxx arvinxx pinned this issue Feb 6, 2025
@dosubot dosubot bot added the ⚡️ Performance Performance issue | 性能问题 label Feb 6, 2025
@hedeqiang

This comment has been minimized.

@lobehubbot

This comment has been minimized.

@arvinxx

This comment has been minimized.

@lobehubbot

This comment has been minimized.

@BryceWG

This comment has been minimized.

@lobehubbot

This comment has been minimized.

@hedeqiang

This comment has been minimized.

@arvinxx

This comment has been minimized.

@lobehubbot

This comment has been minimized.

@YANANEER

This comment has been minimized.

@lobehubbot

This comment has been minimized.

@arvinxx

This comment has been minimized.

@lobehubbot

This comment has been minimized.

@arvinxx

This comment has been minimized.

@lobehubbot

This comment has been minimized.

@arvinxx arvinxx changed the title Docker v1.51.4+ 页面静态化问题反馈(NextAuth 登录、FEATURE_FLAGS 等) Docker v1.51.4+ 页面静态化问题反馈(NextAuth 登录、FEATURE_FLAGS 、请求500 报错等) Feb 6, 2025
@Alencryenfo

This comment has been minimized.

@lobehubbot

This comment has been minimized.

@nzhdotme

This comment has been minimized.

@lobehubbot

This comment has been minimized.

@arvinxx

This comment has been minimized.

@lobehubbot

This comment has been minimized.

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@morningtzh This is a problem that will occur after the image is automatically installed by npm@10. Check whether the entire repository code is exactly the same as the current main branch.

@morningtzh
Copy link

@morningtzh 这个是构建镜像自动装了 pnpm@10 之后会出现的问题,检查下整个仓库代码是否和目前主分支完全一致

从日志上看还是pnpm 9.15.5 的。镜像构建依然使用 ./lobechat/Dockerfile.database 进行构建的。
Image

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@morningtzh This is a problem that will occur after building the mirror automatically installing pnpm@10. Check whether the entire repository code is exactly the same as the current main branch.

From the log, it is still pnpm 9.15.5. Mirror builds are still built using ./lobechat/Dockerfile.database.
Image

@SAnBlog

This comment has been minimized.

@arvinxx

This comment has been minimized.

@lobehubbot

This comment has been minimized.

@SAnBlog

This comment has been minimized.

@lobehubbot

This comment has been minimized.

@fashioncj

This comment has been minimized.

@daiaji
Copy link

daiaji commented Feb 15, 2025

podman logs lobe-chat
🌐 DNS Server: [ '169.254.1.1', '10.10.10.1', 'fd3c:731a:706b::1' ]
-------------------------------------
[Database] Start to migration...
✅ database migration pass.
-------------------------------------
   ▲ Next.js 15.1.7
   - Local:        http://vps:3210
   - Network:      http://vps:3210

 ✓ Starting...
 ✓ Ready in 60ms
{
  allowDangerousEmailAccountLinking: true,
  clientId: undefined,
  clientSecret: undefined,
  platformType: 'WebsiteApp',
  profile: [Function: profile]
}
{
  allowDangerousEmailAccountLinking: true,
  clientId: undefined,
  clientSecret: undefined,
  platformType: 'WebsiteApp',
  profile: [Function: profile]
}
[rewrite] / -> http://127.0.0.1:3210/zh-CN__0__dark
(node:19) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Failed to proxy http://127.0.0.1:3210/zh-CN__0__dark Error: connect ECONNREFUSED 127.0.0.1:3210
    at <unknown> (Error: connect ECONNREFUSED 127.0.0.1:3210) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 3210
}
Error: connect ECONNREFUSED 127.0.0.1:3210
    at <unknown> (Error: connect ECONNREFUSED 127.0.0.1:3210) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 3210
}
[rewrite] / -> http://127.0.0.1:3210/zh-CN__0__dark
Failed to proxy http://127.0.0.1:3210/zh-CN__0__dark Error: connect ECONNREFUSED 127.0.0.1:3210
    at <unknown> (Error: connect ECONNREFUSED 127.0.0.1:3210) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 3210
}
Error: connect ECONNREFUSED 127.0.0.1:3210
    at <unknown> (Error: connect ECONNREFUSED 127.0.0.1:3210) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 3210
}

忽然就没法用了,就是静态化的问题吗?

@arvinxx
Copy link
Contributor Author

arvinxx commented Feb 15, 2025

@daiaji 试下MIDDLEWARE_REWRITE_THROUGH_LOCAL=0

@daiaji
Copy link

daiaji commented Feb 15, 2025

@arvinxx

ss -lt4 -p
State       Recv-Q      Send-Q             Local Address:Port                   Peer Address:Port      Process                            
LISTEN      0           511                  10.10.10.10:3210                        0.0.0.0:*                                            
LISTEN      0           511                  10.10.10.10:2999                        0.0.0.0:*                                            
LISTEN      0           511                      0.0.0.0:8000                        0.0.0.0:*          users:(("node",pid=2,fd=17))      
LISTEN      0           200                      0.0.0.0:postgresql                  0.0.0.0:*                                            
LISTEN      0           4096                   127.0.0.1:2019                        0.0.0.0:*                                            
LISTEN      0           4096                   127.0.0.1:9000                        0.0.0.0:*        
ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 65520 qdisc fq_codel state UNKNOWN qlen 1000
    link/ether 8e:ff:52:ff:ff:ff brd ff:ff:ff:ff:ff:ff
    inet 10.10.10.10/24 brd 10.10.10.255 scope global br0
       valid_lft forever preferred_lft forever                                 

我大概知道这是为什么了,不知道是新版node.js还是新版next.js的锅,你指定监听0.0.0.0:3210它实际上监听的是你的默认网卡的IP,转发的话没啥所谓,但是访问127.0.0.1:3210就不太行了。
2999是nextchat我猜是next.js的问题。
想到监听默认网卡IP这点子的,只能说治好了也流口水。
但话说回来,我不知道该怎么解决。

@arvinxx
Copy link
Contributor Author

arvinxx commented Feb 15, 2025

@daiaji 没懂,MIDDLEWARE_REWRITE_THROUGH_LOCAL=0 这个为啥没法解决呢?

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@daiaji I don’t understand, why can’t this be solved? MIDDLEWARE_REWRITE_THROUGH_LOCAL=0?

@daiaji
Copy link

daiaji commented Feb 15, 2025

@daiaji 没懂,MIDDLEWARE_REWRITE_THROUGH_LOCAL=0 这个为啥没法解决呢?

这不是头疼治头,脚疼治脚吗?

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@daiaji I don’t understand, why can’t this be solved?

Isn’t this a headache to treat the head, and is it a pain in the feet to treat the feet?

@arvinxx
Copy link
Contributor Author

arvinxx commented Feb 15, 2025

@daiaji 没懂,MIDDLEWARE_REWRITE_THROUGH_LOCAL=0 这个为啥没法解决呢?

这不是头疼治头,脚疼治脚吗?

加上这个理论上就能发送外部请求,至少应该就不会报错了吧

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@daiaji I don’t understand, why can’t this be solved?

Isn’t this a headache to treat the head, and is it a pain to treat the feet?

In addition, this theory can send external requests, at least it shouldn't be reported.

@daiaji
Copy link

daiaji commented Feb 16, 2025

@daiaji 没懂,MIDDLEWARE_REWRITE_THROUGH_LOCAL=0 这个为啥没法解决呢?

这不是头疼治头,脚疼治脚吗?

加上这个理论上就能发送外部请求,至少应该就不会报错了吧

只是从解决问题来说,没错,我一开始出问题时就已经降级版本了。
但这不是优化就没吃到了?

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@daiaji I don’t understand, why can’t this be solved?

Isn’t this a headache to treat the head, and is it a pain to treat the feet?

In addition, this theory can send external requests, at least it shouldn't report an error

Just from the point of solving the problem, that's right, I downgraded the version when there was a problem at the beginning.
But isn’t this an optimization that I didn’t eat it?

@SAnBlog
Copy link

SAnBlog commented Feb 16, 2025

v1.56.2

Image

进入到应用设置界面后再点击会话界面,模型变成4o-mini,提示词清空

@SAnBlog
Copy link

SAnBlog commented Feb 16, 2025

v1.56.2

Image

进入到应用设置界面后再点击会话界面,模型变成4o-mini,提示词清空

刷新后恢复

ramu-narasinga pushed a commit to ramu-narasinga/lobe-chat that referenced this issue Feb 17, 2025
This upgrade includes two changes:

For users deploying with Vercel using next-auth, it is necessary to add the environment variable `NEXT_PUBLIC_ENABLE_NEXT_AUTH=1` to ensure Next Auth is enabled; other users are not affected.
For users using clerk in self-built images, it is necessary to additionally configure `NEXT_PUBLIC_ENABLE_NEXT_AUTH=0` to disable Next Auth

Other standard deployment scenarios (using Clerk in Vercel and using next-auth in Docker) are not affected

For More detail, refer to lobehub#5804

本次升级存在两个变更:

- 针对使用 Vercel 部署中使用 next-auth 的用户,需要额外添加 `NEXT_PUBLIC_ENABLE_NEXT_AUTH=1` 环境变量来确保开启 Next Auth
- 针对使用自构建镜像中使用 clerk 的用户,需要额外配置 `NEXT_PUBLIC_ENABLE_NEXT_AUTH=0` 环境变量来关闭 Next Auth

其他标准部署场景(Vercel 中使用 Clerk 与 Docker 中使用 next-auth )不受影响

变更详情原因查看 lobehub#5804
@arvinxx
Copy link
Contributor Author

arvinxx commented Feb 17, 2025

经过2周疯狂优化,目前应该已经稳定。本 issue 关闭

@arvinxx arvinxx closed this as completed Feb 17, 2025
@lobehub lobehub locked as resolved and limited conversation to collaborators Feb 17, 2025
@lobehubbot
Copy link
Member

@arvinxx

This issue is closed, If you have any questions, you can comment and reply.
此问题已经关闭。如果您有任何问题,可以留言并回复。

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


After 2 weeks of crazy optimization, it should be stable at present. This issue closes

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
⚡️ Performance Performance issue | 性能问题
Projects
None yet
Development

No branches or pull requests