fix(webhook): treat HTTP 409 (rebuild already running) as success, not error
The pmtiles-webhook returns 409 when a rebuild is already in progress. Previously this was treated as a failure, showing 'Webhook PMTiles indisponibil' error to the user. Now 409 is handled as a valid state with appropriate messaging. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -162,8 +162,8 @@ export async function POST(request: NextRequest) {
|
||||
if (action === "rebuild") {
|
||||
// Get current PMTiles state before rebuild
|
||||
const before = await getPmtilesInfo();
|
||||
const ok = await firePmtilesRebuild("manual-rebuild");
|
||||
if (!ok) {
|
||||
const result = await firePmtilesRebuild("manual-rebuild");
|
||||
if (!result.ok) {
|
||||
return NextResponse.json(
|
||||
{ error: "Webhook PMTiles indisponibil — verifica N8N_WEBHOOK_URL si serviciul pmtiles-webhook" },
|
||||
{ status: 500 },
|
||||
@@ -172,8 +172,11 @@ export async function POST(request: NextRequest) {
|
||||
return NextResponse.json({
|
||||
ok: true,
|
||||
action: "rebuild",
|
||||
alreadyRunning: result.alreadyRunning ?? false,
|
||||
previousPmtiles: before,
|
||||
message: "Rebuild PMTiles pornit. Dureaza ~8 min. Urmareste PMTiles last-modified.",
|
||||
message: result.alreadyRunning
|
||||
? "Rebuild PMTiles deja in curs. Urmareste PMTiles last-modified."
|
||||
: "Rebuild PMTiles pornit. Dureaza ~8 min. Urmareste PMTiles last-modified.",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user