fix: redirect cold translation misses#610
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe translation worker updates its AI model from Llama-3.1-8b to Kimi-K2.6 and replaces synchronous 503 error responses with asynchronous cache refresh behavior. On cache misses, the worker returns a 302 redirect to the default locale while scheduling background translation generation, and expands AI response parsing to handle OpenAI-style choice structures. Changes
Sequence DiagramsequenceDiagram
actor Client
participant Worker as Translation Worker
participant Cache
participant AI as AI Model
Client->>Worker: Request translation
Worker->>Cache: Check cache
alt Cache Hit
Cache-->>Worker: Translation found
Worker-->>Client: 200 + Translation
else Cache Miss
Cache-->>Worker: Not found
Worker->>AI: Schedule background refresh
activate AI
Worker-->>Client: 302 redirect to default locale
Note over Worker: Response sent immediately
AI->>Cache: Generate & store translation
AI-->>Worker: Done (background)
deactivate AI
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 0/5 reviews remaining, refill in 51 minutes and 59 seconds. Comment |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a492c5fb1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| refreshCache(request, env, requestUrl, locale, cacheKey).catch((error) => { | ||
| console.error('Failed to create translated page', { pathname: requestUrl.pathname, locale, error }) | ||
| }), | ||
| ) | ||
| return temporaryEnglishRedirectResponse(requestUrl, isHead) |
There was a problem hiding this comment.
Return origin status on cold misses for non-cacheable pages
On a cache miss this branch always returns a 302 to the English URL, but refreshCache only stores responses when response.ok && isHtmlResponse(response). That means localized requests whose English origin returns a redirect, 404, or any non-HTML response will never populate cache and will be permanently redirected to English on every request (e.g. /fr/... pages that should be 301/404). This is a behavior regression from the previous flow, which returned the actual origin status on first request.
Useful? React with 👍 / 👎.




What changed
@cf/moonshotai/kimi-k2.6.choices[].message.contentresponses so Kimi output is accepted.Validation
bun run ci:verify:translationSummary by CodeRabbit
New Features
Improvements