真机 ORD_WEB_20261018_BR002_0002:建单中断留空坑 ⇒ 10 分钟内该配送日所有推送被跳过且返回 200, 主系统记 success、我方零导入 ⇒ 表现为"有时成功有时失败"。 · claimDayOrder 陈旧空坑判定 10 分钟 → 2 分钟(正常建单秒级,2 分钟足够区分并发与崩溃遗留); · webhook 对"占坑未取得"返回 503 + Retry-After:30 + retryable:true,让主系统按契约重试; 同时我方下一轮(≤2 分钟)可重占空坑,两边都不需人工介入。 验证:tsc 0 错;新增 mainSystemImportInFlight 2 条。
27 lines
1.2 KiB
TypeScript
27 lines
1.2 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
||
import path from 'node:path';
|
||
import { describe, expect, it } from 'vitest';
|
||
|
||
/**
|
||
* 「占坑未取得」不得静默丢单(2026-10-18 真机 `ORD_WEB_20261018_BR002_0002`:
|
||
* 一次建单中断留下空坑 ⇒ 10 分钟内该配送日所有推送被跳过且返回 200,主系统记成功、我们没导入)。
|
||
*/
|
||
const importer = readFileSync(path.join(__dirname, '../src/services/mainSystemOrderImport.ts'), 'utf8');
|
||
const routes = readFileSync(path.join(__dirname, '../src/routes/mainSystemIntegration.ts'), 'utf8');
|
||
|
||
describe('① 空坑可重占窗口:10 分钟 → 2 分钟', () => {
|
||
it('占坑 CAS 用 2 分钟陈旧判定', () => {
|
||
expect(importer).toMatch(/created_at < NOW\(\) - INTERVAL '2 minutes'/);
|
||
expect(importer).not.toMatch(/created_at < NOW\(\) - INTERVAL '10 minutes'/);
|
||
});
|
||
});
|
||
|
||
describe('② 对方能感知"本轮没导入":503 + Retry-After', () => {
|
||
it('占坑未取得 ⇒ 503 retryable(不再 200 当成功)', () => {
|
||
expect(routes).toMatch(/import_in_flight/);
|
||
expect(routes).toMatch(/Retry-After/);
|
||
expect(routes).toMatch(/status\(503\)/);
|
||
expect(routes).toMatch(/retryable: true/);
|
||
});
|
||
});
|