fix(vercel): 解决 Vercel 环境下启用自动删除会话失效#474
Merged
CJackHwang merged 2 commits intoCJackHwang:devfrom May 10, 2026
Merged
Conversation
The "delete current conversation" feature was not working on Vercel deployment because the stream flow uses a separate lease mechanism. The session_id created during prepare phase was not preserved for deletion when the stream ends. Changes: - Add SessionID field to streamLease struct to preserve session_id - Pass session_id to holdStreamLease during prepare - Modify releaseStreamLease to return auth and session_id - Call autoDeleteRemoteSession in handleVercelStreamRelease when releasing a lease with auto-delete mode enabled Closes #vercel-auto-delete
|
Someone is attempting to deploy a commit to the cjack's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df6859bddc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
在 Vercel 部署环境中,"删除当前对话"功能无法正常工作。用户开启自动删除后,对话仍然不会被删除。
问题分析
在 Vercel 部署环境中,流式请求使用了一种特殊的 "prepare-release" 两阶段流程:
session_id,但由于 Vercel 的冷启动优化,实际请求处理转移到 Node.js 端原来的代码问题在于:
sessionID没有保存到 lease 中修复内容
1. handler.go
给
streamLease结构体添加SessionID字段,用于保存会话 ID:2. vercel_stream.go
holdStreamLease函数添加sessionID参数releaseStreamLease函数返回(bool, *auth.RequestAuth, string)三个值,包含认证信息和会话 IDhandleVercelStreamRelease在释放时调用autoDeleteRemoteSession触发自动删除3. vercel_prepare_test.go
TestStreamLeaseLifecycle适配新签名TestHandleVercelStreamReleaseTriggersAutoDelete验证 Vercel 流释放时的自动删除功能预期效果
当用户开启"仅删除当前对话"(auto_delete_mode=single)时:
测试结果
所有相关单元测试均已通过:
TestHandleVercelStreamReleaseTriggersAutoDeleteTestStreamLeaseLifecycleTestChatCompletionsAutoDeleteModes影响范围
此修改仅影响 Vercel 流式部署