fix(server): SYB 会话到期前提前续登,同步预检遇到未登录时重新登录并重试一次 #371
Open
opened 2026-10-09 09:47:51 +08:00 by ila
·
0 comments
No Branch/Tag Specified
main
fix/370-horizontal-grid
feat/372-export-shop
feat/378-heartbeat-diagnostics
feat/372-export-price
feat/372-list-export
fix/377-rejected-purchase-outbox
fix/376-pre-address-spec-verification
fix/374-final-spec-confirmation
fix/373-navigation-diagnostics
fix/370-color-discovery
feat/367-last-batch-repurchase
fix/368-image-search-partial-link
integration/364-365-366-main
feat/364-purchase-failure-snapshot
integration/365-366-validation
fix/365-order-result-observation
fix/366-address-editor-ready
fix/359-auto-match-resume
feat/363-inner-code-page-size
fix/362-truncated-spec-card
fix/361-spec-probe-click
docs/agents-worktree-rules
fix/358-syb-size-weight
feat/357-syb-cancel-status
feat/356-purchase-order-filter
fix/355-syb-list-timeout
feat/353-syb-shop-multiselect
fix/354-syb-top-pagination
fix/352-syb-source-created
fix/348-reveal-swipe
feat/340-syb-excluded-products
fix/351-inner-code-apply-selection
fix/350-match-layout
fix/350-inner-code-matching
feat/349-batch-return-use
feat/347-batch-return-cancel
feat/345-yeeke-reship
fix/346-root-serves-spa
fix/344-inner-code-stall-match
fix/343-syb-writeback-session
feat/339-syb-page-size
feat/338-return-match
feat/337-yeeke-admin-ui
feat/336-yeeke-return-sync
fix/335-bottom-submit-node
fix/334-spec-probe-top-swipe
fix/333-purchaser-device-owner
fix/331-spec-panel-recognition
fix/330-syb-writeback-session
feat/327-syb-writeback-filter
feat/326-order-information
fix/325-order-result
feat/316-chrome-order-backfill
fix/307-backfill-entry
feat/305-syb-order-writeback
feat/306-order-paid-amount
release/283
fix/283-purchase-mapping-consistency
fix/230-horizontal-spec-selection
feat/263-spec-rematch
fix/262-purchase-handoff
fix/260-261-purchase-readiness
fix/259-partial-collection-link
feat/258-one-click-replace
fix/257-color-normalized-match
fix/256-collection-single-dimension
fix/255-current-page-reidentify
feat/253-one-click-link
fix/254-match-loading
fix/251-syb-spec-candidates
feat/250-continuous-collection
fix/249-local-purchase-diagnostics
fix/248-bottom-submit
fix/247-short-address-panel
fix/246-address-return-panel
fix/245-purchase-failure-diagnostics
fix/244-selected-card-duplicates
fix/243-spec-entry-recovery
feat/242-agent-order-backfill
feat/241-order-backfill-endpoint
fix/239-syb-partial-sync
fix/238-spec-panel-preswipe
feat/237-client-api-keys
feat/236-purchaser-syb-sync
fix/235-syb-pagination-overlap
release/234-integrated
fix/229-address-entry-dedup
fix/228-selection-proof-panel-transition
fix/227-address-panel-return
fix/226-reopen-pdd-on-manual-retry
fix/225-in-place-purchase-retry
fix/224-final-spec-revalidation
fix/223-probed-confirmed-mapping
chore/221-devharness-sync
feat/218-purchase-result-bubble
fix/217-agent-retry-current-spec
fix/216-syb-spec-role-order
feat/215-mandatory-live-spec-probe
feat/214-verified-purchase-actions
fix/212-syb-sync-shop-snapshot
feat/211-spec-entry-ready-wait
feat/210-order-result-payment-transition
feat/209-pdd-bottom-spec-entry
feat/200-ai-match-result-purchase-ready
feat/199-job-execution-logs
feat/198-syb-ai-parse
feat/195-scheduled-spec-auto-match
fix/197-ai-write-timeout
feat/190-syb-inline-correction
fix/193-address-entry-reveal
feat/194-one-click-spec-match
fix/192-order-result-scroll
No results found.
Labels
No items
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: OPC/goauto#371
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
基本信息
已核验事实
线上数据(只读查询,2026-10-09)
failed:「查询 2026-10-09 货运单总数失败: 顺运宝接口 /am/stock/listTotal: 用户未登录: 顺运宝会话未登录或已过期」syb_session.updated_at= 09:36:51.396,expires_at= 10-10 09:36:51.000(取 JWT exp,精确到秒),说明此次重新登录成功代码事实(
origin/maine450ac28989de6827328b411e4bdc050dded9ab3)sybclient/client.goLogin:ExpiresAt = min(JWT exp, now+24h),没有提前量。docs/12 §3.3:会话正好 24 小时,不滚动续期。sybclient/session.goLoad:now >= ExpiresAt才返回ErrNoSession。sybclient/session_manager.goAcquireSession:只在开始时判断:缓存未过期,并且CheckSession(GET /am/user/get)有效,就直接复用。sybimport/sync.goSyncWithShopSnapshot:先对每个日期调用ListTotal做预检(不写任何数据),预检失败直接返回;注释写明「a session that dies mid-run surfaces as ErrSessionInvalid and is treated like any other mid-run failure」,没有重新登录后重试。sybimport/import_handler.gorunImport:Connect→SyncWithShopSnapshot,出错即failed,没有重试。SessionStore.Delete在生产代码中没有调用方;docs/12 §3.5 写「判定未登录,清会话」,但实际没有清除。AcquireSession的其他调用方:订单回写(purchase/order_writeback_worker.go)、入库码(sybinnercode/runtime.go经sybimport.Connect)、店铺发现(Discover)。推断(证据较强,未看服务日志,未完全证实)
1107 正好在会话失效前一两秒开始:本地缓存未过期,
CheckSession也有效;约 1 秒后ListTotal时会话到期,顺运宝返回「用户未登录」。推测前一天 09:05 的同步(1083)在开始时重新登录过,所以会话第二天同一时刻失效。
整点定时 + 24 小时硬上限 + 没有提前量,会让这种情况在某些小时反复出现:只要某次 xx:05 的同步刚好重新登录,第二天同一时刻就可能撞上。
目标
非目标
CheckSession判定规则、网络故障与未登录的区分(§3.5)、OCR 登录流程与登录租约。方案
sybclient)now + 提前量和ExpiresAt比较;剩余时间不足提前量就当作已过期,走现有的租约 + OCR 登录流程。Load的现有语义和测试可以保留,改为调用方传入time.Now().Add(margin),或新增带提前量的方法,由实施时选最小改法。validSessionOrError)必须对新会话成立,不能因为提前量导致刚登录的会话被判定不可用。validCachedSession)使用同一个提前量,避免等到即将过期的旧会话。sybimport)ListTotal,尚未写任何数据)返回errors.Is(err, sybclient.ErrSessionInvalid)时触发;用可区分的错误类型标明「预检阶段」,不靠匹配错误文字判断。SessionStore.Delete,这里符合 §3.5「明确未登录才清会话」),再走Connect重新登录,然后重新执行同一次同步。最多重试一次;第二次仍失败就按原逻辑记失败,错误信息保留两次的原因(不含 Cookie、Token、密码)。syb_sync_run记录内完成,不新建同步记录,进度从 0 重新开始。子项目影响、依赖与并行
sybclient/session_manager.go(及session.go,如需要)、sybimport/sync.go、sybimport/import_handler.go,以及对应测试。设计证据
非 UI 改动,无需原型;以本正文为准。
验收标准
AcquireSession走登录流程;剩余时间充足时复用缓存,不请求验证码。ListTotal首次返回「未登录」→ 删除缓存 → 重新登录 → 第二次成功,同步结果为成功,只登录一次。failed,错误信息含原因且不含凭据。sybclient、sybimport、purchase(订单回写)、sybinnercode相关回归测试通过;服务端构建通过,如实记录。syb_sync_run与syb_session确认。发布需用户另行授权。风险与回退
AcquireSession和登录租约重新获取,不会重复请求验证码。文档影响
备注
本单由 Claude Code 依据线上只读查询和代码阅读起草;不含账号、密码、Cookie 或 Token。