From 5728c42ab795f062ea531dee81f562b1fe199659 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 16 May 2026 03:14:30 +0900 Subject: [PATCH] fix(import): ignore stale probe responses on URL change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If user changed the URL while a probe was in flight, the late response for the old URL would still set lastProbedUrl and enable the start button, breaking the "확인 전 가져오기 차단" UI invariant. Drop the response (and the catch path, and the post-confirm path) when the current input no longer matches the probed URL. Co-Authored-By: Claude Opus 4.7 --- public/editor.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/public/editor.js b/public/editor.js index 66d8d71..7f66c4f 100644 --- a/public/editor.js +++ b/public/editor.js @@ -94,6 +94,11 @@ headers: { 'content-type': 'application/json' }, body: JSON.stringify({ url: url }) }).then(function (r) { return r.json() }).then(function (j) { + // stale probe 응답 무시: 사용자가 그동안 입력을 바꿨으면 이 응답으로 + // UI 상태 (lastProbedUrl, 버튼 enable, probeInfo, title) 를 갱신하면 안 된다. + // (race: URL A 로 probe → 응답 도착 전 URL B 로 수정 → A 응답이 B 의 + // 가져오기 버튼을 켜버리는 버그.) + if (ytUrl.value.trim() !== url) return if (!j.ok) { probeInfo.textContent = j.message || '확인 실패' ytProbeBtn.disabled = false @@ -113,11 +118,15 @@ return } } + // confirm 동안에도 사용자가 입력을 바꿨을 수 있으므로 한 번 더 검증. + if (ytUrl.value.trim() !== url) return if (!titleInput.value) titleInput.value = p.title // 이 URL 에 한해 확인 활성화. URL 변경 감지용으로 마지막 probe URL 저장. lastProbedUrl = url ytStartBtn.disabled = false }).catch(function (e) { + // 마찬가지로 stale 응답이면 무시 (현재 입력값에 영향 안 주게). + if (ytUrl.value.trim() !== url) return probeInfo.textContent = '확인 실패: ' + e.message ytProbeBtn.disabled = false })