Repository navigation
fix(core): keep locale across async withLocale without ALS - #9008
Merged
Merged
Conversation
try/finally restored _locale as soon as fn returned a Promise, so getLocale() threw after await when AsyncLocalStorage was missing.
🦋 Changeset detectedLatest commit: 3a0b961 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Varixo
reviewed
Sep 14, 2026
Varixo
left a comment
Member
There was a problem hiding this comment.
hey! thanks for the PR, added small comment
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
@Varixo |
Varixo
enabled auto-merge (squash)
September 14, 2026 20:06
@qwik.dev/core
@qwik.dev/router
@qwik.dev/utils
eslint-plugin-qwik
create-qwik
@qwik.dev/optimizer
@qwik.dev/devtools
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is it?
Description
withLocale('zh-CN', async () => { ... })is supposed to keepgetLocale()aszh-CNfor the whole function, including afterawait.That already works when AsyncLocalStorage is present. When it is not (browser build, some edge runtimes), the old code used
try/finally. Thefinallyruns the moment the function returns a Promise, so afterawaitthe locale is gone andgetLocale()throwsReading locale outside of context.This change waits until that Promise finishes (success or error), then puts the previous locale back. Sync
withLocaleis unchanged.Related: this is the leftover hole after #8999, which taught Qwik how to find ALS on more runtimes. This PR is about the path that still has no ALS.
Checklist
pnpm change