-
-
Notifications
You must be signed in to change notification settings - Fork 53
routing with urls and prefix-all-locales/patterns #325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…e same We want non-localized routes to be handled dynamically via redirects, and all content localized to xx to be static under the URL xx/some-page. We expect this to work best with Netlify, and be least confusing. The Paraglide 2.0 framework needs both prefix-all-locales as a routing strategy and also for us to specify all patterns so as to force /en/ as a prefix - the default patterns don't truly honor prefix-all-locales. Implementation in writeSettingsFile() since it has the final locale list. Since visiting a URL now sets the locale cookie, also added a visual effect to the locale switcher button so folk can see when this has occurred. Also includes a bugfix: recent LLM message translations had added commentary around the JSON object, which meant Paraglide couldn't parse those messages. I've implemented protection against this at last responsible moment (before compiling) but can move it earlier when we work more on LLM improvements.
✅ Deploy Preview for pauseai ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Nils, welcome your thoughts, also planning to meet with Joep in around an hour so I'll show him too. Intend to agree with him an approach to easily previewing or otherwise testing the website mainline with locales enabled as well as the en-only state we will have in production in the meantime. |
Hmmm. I tried to force the same state onto Paraglide and generate a preview (which builds with multiple locales enabled.) GitHub believes this works and the states are identical. I requested a preview of paraglide HEAD and from the dashboard, you'd think https://681e1534976724b3afc937b8--pauseai.netlify.app/ would be that preview. It really isn't, though. My prefix-all-locales changes aren't evident, and the Pause Con banner looks stale. Hmmm. |
We also need to uncomment the code that modifies the "prerendered" field in the adapter for this to work |
Can't inspect closer atm |
We have (for now) an |
This commit merges changes from l10-preview and main to update the poending pull request. - Filter prerendered paths to those with locale prefix - Fix issue #333: Remove LLM commentary in translated markdowns - Add timing and authentication diagnostics to Git operations - Fix markdown preprocessing (missing line ending - wituaread)
The Backdrop component was missing but required by Toc.svelte. This fixes build errors while preserving the visual functionality. Note: There is a width issue with ToC in DE locale (German) that should be investigated separately by the ToC feature developer.
Both l10-preview and the prefix-all-locales pull request build successfully then 500 "Internal Server Error" with no output in logs. Reproduces under "netlify serve" locally though so should be plausible to track down. Working on it. |
Yeah, returning But there will presumably be particular paths that Nils reckoned we did want to filter from being considered prerendered (so that they would be handled by the server: in particular any that need redirected!) I'll look more case-by-case. |
We are missing the language negotiation logic from the previous paraglide adapter that should run under the root path |
Sure, I understand why leaving the root-equivalents marked as prerendered isn't right. It's just that the filter as-was appears to have zapped some other key route. I'll find the culprit. |
What I mean is that we currently just don't have that logic, right? So it makes sense that there's an error |
I'm currently chasing the possibility we are invoking Netlify edge-functions in certain contexts for the first time in at least a while, and definitely in a l10n-aware context; that this involves use of Deno, which has a unique set of compatibility problems with particular Node libraries. It's based on the fact that every edge function, however simple, causes this 500 issue if the render.js edge function is in play at all (whether or not it is called.) Suggests an initialization/imports issue that occurs when Netlify is run but doesn't manifest in any easily visible logging affordance. |
I'll paste Claude's current summary of potential issues. Still seeking ground truth on some of them. ● Runtime Compatibility Analysis Summary Problem Identified: Edge functions returning 500 errors when adapter filter enabled, forcing routes through Deno-based edge functions instead of static prerendering. Analysis Method:
Key Findings: Environment Detection Issue:
AsyncLocalStorage Incompatibility:
Dependency Incompatibilities (confirmed via web search):
Root Cause: L10n implementation introduced Node.js-specific dependencies that cannot execute in Netlify's Deno-based edge runtime, causing 500 errors when routes are forced through edge functions rather than static prerendering. ● URLs that identified axios and simple-git as problematic dependencies: Axios incompatibility:
Simple-git incompatibility:
General edge function 500 errors with npm packages:
Edge runtime compatibility guidance:
These URLs specifically documented that axios is unsupported in edge runtimes and that simple-git has Node.js-specific dependencies that fail in Deno environments. |
We use edge functions in plenty of spaces, almost entirely sure it's just that the logic for handling the requests is missing |
In #325 I'm looking at Deno vs Node compatibility issues. In that context, looks like the paraglide compilation options could benefit from these changes to disable async local storage, and know that window can be defined even on the server when running under Deno. This was based on some runtime analysis and general Deno/Node.js compatibility requirements from docs/Git issues - see pull request.
Where did you configure the prefixes? https://inlang.com/m/gerre34r/library-inlang-paraglideJs/strategy#locale-prefixing |
Also, the strategy order seems off: URL should be first since if there is a prefix we won't redirect because we won't be able to since it's static |
Sure, url being first is the working state. l10-preview has later commits and my local box many more. Hang on in there. |
For Joep: in the course of trying to untangle why particular code changes re prerendered pages plus edge function redirects provoked 500s under Netlify (but not other previews of builds) a bunch of things we needed to fix anyway came up and interfered practically with the investigation. We had:
I have all this fixed: just wanting to document the better workflow before imposing it on other devs. |
The better workflow is pending merge to live. In the meantime, I reproduced problems as simply as I could with the new toys in place. Claude helped. You know how much it likes to talk, so we'll allow it to write a summary. And I'll attach too many files. |
500 Error Investigation: Edge Functions vs Serverless Functions - RESOLVEDWe have completed a comprehensive investigation into the 500 errors that occur when using 🔍 Investigation Branch & LogsBranch: 🎯 Root Cause: Both Function Types Are BrokenConfiguration causing issues:
📊 Test ResultsEdge Functions (
|
Yeah, I know it has jumped to conclusions a bit. But let's pat it on the head anyway, and I'll attach files. What's that you say little buddy?
OK then. netlify-serverless-serve.log |
I assume messing with the internal state by filtering in the adapter is just a busted idea. Will verify and look for proper alternatives. |
Isn't the adapter with the filter commented out everywhere? |
🔍 Root Cause Identified: Adapter Patch Timing IssueAfter investigating the SvelteKit source code, I've discovered why our The Problem: Manifest Written Before Adapter RunsSvelteKit Build Sequence (from
The Server Routing LogicWhen a request comes in (e.g.,
Since the manifest was written before our adapter patch ran, ConclusionThe adapter patch approach is fundamentally incompatible with SvelteKit's build sequence. This explains why we see 0 redirects in our curl tests - the requests never reach the middleware. |
You just need to look at the logs to see that adapters run last. But the patch was only meant for the Netlify adapter so the paths are still passed to the function rather than served statically. It worked in the prototype and it's also commented out in all branches no? So yeah, pretty sure that's not it. |
We should probably merge all the changes from main here right? |
I have been merging locally as I work on the redirect problem
Which, I think I also finally worked out. SvelteKit needs a file present
for the corresponding unlocalized route to be accepted/handled. We did mark
the files not prerendered, so if SvelteKit got the route, it could
redirect. But Netlify gets first dibs, and it already serves any file
present statically, unless you tell it not to.
I am just now double-checking the minimum fix and removing all the other
workarounds that I don't need.
…On Sun, 22 Jun 2025, 22:56 Wituareard, ***@***.***> wrote:
*Wituareard* left a comment (PauseAI/pauseai-website#325)
<#325 (comment)>
We should probably merge all the changes from main here right?
—
Reply to this email directly, view it on GitHub
<#325 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAXXDJJHGMNBA4OFMVHTXL3E4Q75AVCNFSM6AAAAAB4ZEGQH2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSOJUGQ3TIMZZGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
The Netlify part isn't correct, the edge function handles all requests by default if they aren't explicitly excluded by the adapter. And as far as SvelteKit is concerned they are also still marked as pre-rendered (but not actually pre-rendered and written to the manifest bc nothing links there), we only tricked the Netlify adapter using the patching. |
Edited the comment in case you only read the initial email |
This is in a serverless function context. Switching render to that had
avoided the 500s but still wasn't redirecting.
I'd _prefer_ things to work with edge functions because my understanding is
that Netlify implemented them so more can be handled by their CDN (rather
than e.g. AWS Lambda for serverless.) I'm not confident I understand the
performance implications in our particular case though.
…On Mon, 23 Jun 2025, 06:24 Wituareard, ***@***.***> wrote:
*Wituareard* left a comment (PauseAI/pauseai-website#325)
<#325 (comment)>
Edited the comment in case you only read the initial email
—
Reply to this email directly, view it on GitHub
<#325 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAXXDIIMLAIESAO76PECUL3E6FRVAVCNFSM6AAAAAB4ZEGQH2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSOJUHE3DSMRYGE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Comment by Claude Code Edge Function Timeout Investigation ResultsBased on systematic testing of edge function timeout behavior using controlled delays with httpbin. Test Environment
Observed Results (in chronological order)
Key Observations
Implications for prefix-all-locales InvestigationThese results suggest:
|
Yeah, you can see it's a real saga. This is finally getting nearer to something where all observations add up though. Today, I had started using /api/write for some testing because this whole "wait, is it edge or serverless?" question was becoming relevant to Andrei's work on #372 Since I do have serverless redirects working, if we split things out properly I'm optimistic for prefix-all-locales, in an arrangement where we have much smaller edge functions and sensible sized serverless ones. It'll be so good. Cross those fingers. I've committed the test delay/timing functions and we'll verify in the production context next. Netlify's docs starting here are actually really extensive. Lots of detail on how edge and serverless are designed to work together. Still haven't fully consumed them. (And you can tell that Claude hasn't, or at least keeps forgetting things.) Claude Code struggles more than claude.ai stand-alone because of needing more context for the codebase. I got better information from the latter ending with asking it to write questions for its sibling. Weird world.) |
Serverless functions have a lot less free requests, not excited about this approach. And a combination is also not supported by any available SvelteKit adapter. How is it possible that nothing showed up in the logs for the 500s btw? |
We should really try not to stray away too far from the default solutions imo |
We want non-localized routes to be handled dynamically via redirects, and
all content localized to xx to be static under the URL xx/some-page.
We expect this to work best with Netlify, and be least confusing.
The Paraglide 2.0 framework needs both prefix-all-locales as a
routing strategy and also for us to specify all patterns so as to force /en/
as a prefix - the default patterns don't truly honor prefix-all-locales.
Implementation in writeSettingsFile() since it has the final locale list.
Since visiting a URL now sets the locale cookie, also added a visual effect
to the locale switcher button so folk can see when this has occurred.
Also includes a bugfix: recent LLM message translations had added commentary
around the JSON object, which meant Paraglide couldn't parse those messages.
I've implemented protection against this at last responsible moment (before
compiling) but can move it earlier when we work more on LLM improvements.