fix(worker): 修复寄卖页分片加载失败导致的白屏
- 新增全局/页面级错误边界,页面渲染异常不再整页白屏 - 监听 vite:preloadError,部署后旧分片加载失败自动刷新一次 - 修复长会话 setTimeout 2^31 溢出导致立即登出 - 寄卖页资料接口失败给出重试态,不再误报未开通
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import {
|
||||
MAX_TIMER_DELAY_MS,
|
||||
hasRemainingTimerDelay,
|
||||
resolveTimerChunkDelay,
|
||||
} from '../src/utils/session-expiry-timer.ts'
|
||||
|
||||
const DAY_MS = 24 * 60 * 60 * 1000
|
||||
|
||||
test('7 天会话有效期不需要切段', () => {
|
||||
assert.equal(resolveTimerChunkDelay(7 * DAY_MS), 7 * DAY_MS)
|
||||
assert.equal(hasRemainingTimerDelay(7 * DAY_MS), false)
|
||||
})
|
||||
|
||||
test('30 天会话有效期超过 32 位上限时切段,避免 setTimeout 溢出后立即触发', () => {
|
||||
const thirtyDays = 30 * DAY_MS
|
||||
assert.ok(thirtyDays > MAX_TIMER_DELAY_MS)
|
||||
assert.equal(resolveTimerChunkDelay(thirtyDays), MAX_TIMER_DELAY_MS)
|
||||
assert.equal(hasRemainingTimerDelay(thirtyDays), true)
|
||||
})
|
||||
|
||||
test('刚好等于上限时不切段', () => {
|
||||
assert.equal(resolveTimerChunkDelay(MAX_TIMER_DELAY_MS), MAX_TIMER_DELAY_MS)
|
||||
assert.equal(hasRemainingTimerDelay(MAX_TIMER_DELAY_MS), false)
|
||||
})
|
||||
|
||||
test('已过期/非法延迟按 0 处理', () => {
|
||||
assert.equal(resolveTimerChunkDelay(0), 0)
|
||||
assert.equal(resolveTimerChunkDelay(-1), 0)
|
||||
assert.equal(resolveTimerChunkDelay(Number.NaN), 0)
|
||||
assert.equal(hasRemainingTimerDelay(Number.NaN), false)
|
||||
})
|
||||
Reference in New Issue
Block a user