Skip to content

Conversation

@anthonybailey
Copy link
Collaborator

Summary

Fixes the paraglide window.location crash on cold Netlify edge function starts and removes the now-unnecessary importRuntimeWithoutVite() workaround.

(Apologies for the branch name pun - couldn't resist "deno-uncement" for removing cemented workarounds from our Deno edge code!)

Problem

Netlify's Deno 2.3.1 edge runtime provides a partial window stub where window exists but window.location is undefined. This breaks paraglide-js which assumes window.location exists if window exists, causing HTTP 500 errors on first request to dynamic pages.

Solution

  1. Runtime workaround: Delete the incomplete window stub in hooks.server.ts before paraglide loads, making Netlify's Deno behave like standard Deno/Node.js
  2. Code cleanup: Remove importRuntimeWithoutVite() function and use simple static imports now that we use paraglide's default isServer check

Changes

  • Add window deletion in src/hooks.server.ts (detects Netlify Deno environment)
  • Remove custom isServer override in scripts/inlang-settings.ts (use paraglide default)
  • Remove importRuntimeWithoutVite() workaround function
  • Simplify script imports to use static imports where possible

Testing

  • ✅ Local: pnpm dev, netlify serve
  • ✅ CI: Full clean build (clean → inlang:settings → check → lint) passes
  • ✅ Production: Tested on PR Diagnose edge function Deno version #544 preview deployment
    • Cold edge function /people request: HTTP 200 (was HTTP 500)
    • Multiple pages and API endpoints verified working

Related Issues

Fixes: #538, #540

See: notes/20251113-paraglide-edge-function-investigation.md

🤖 Generated with Claude Code

Anthony Bailey and others added 2 commits November 14, 2025 21:45
Implements window deletion approach to fix paraglide crash on cold edge
function starts. Netlify's Deno 2.3.1 provides partial window object
(window exists but window.location undefined) which breaks paraglide-js.

Changes:
- Add window deletion in hooks.server.ts before paraglide imports
- Remove custom isServer override (use paraglide default)
- Clarify disableAsyncLocalStorage comment for serverless context

The fix detects Netlify's Deno environment and removes the incomplete
window stub, making it behave like standard Deno/Node.js where window
is properly undefined during SSR.

See: notes/20251113-paraglide-edge-function-investigation.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
With paraglide's default isServer check, we no longer need the
importRuntimeWithoutVite() workaround that patched 'import.meta.env.SSR'.

Changes:
- Remove importRuntimeWithoutVite() function from utils.ts
- Use static imports in vite.config.ts, l10ntamer.ts, and check-setup-needed.js
- Keep dynamic await import() only in run.ts (bootstraps runtime.js)
- Update test mocks to mock runtime module directly

All scripts can use static imports since runtime.js is generated
before checks run (via pnpm inlang:settings in CI).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@netlify
Copy link

netlify bot commented Nov 15, 2025

Deploy Preview for pauseai ready!

Name Link
🔨 Latest commit 2c3efa7
🔍 Latest deploy log https://app.netlify.com/projects/pauseai/deploys/6918235fdbaa1a0008ee5b39
😎 Deploy Preview https://deploy-preview-548--pauseai.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 54 (🟢 up 8 from production)
Accessibility: 89 (no change from production)
Best Practices: 100 (no change from production)
SEO: 99 (🟢 up 1 from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Collaborator

@Wituareard Wituareard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work, I completely forgot about the importRuntimeWithoutVite hack

@anthonybailey anthonybailey merged commit 8b531a2 into main Nov 15, 2025
5 checks passed
@anthonybailey anthonybailey deleted the deno-uncement branch November 15, 2025 14:57
anthonybailey pushed a commit that referenced this pull request Nov 15, 2025
Re-add People page with AirTable integration

Restores the People of PauseAI page, now pulling data from AirTable Members table
to showcase staff and key contributors.

The page encountered edge function issues with HTTP 500 errors on cold starts
due to Netlify's Deno runtime providing a partial window object that broke
paraglide-js. This was investigated in #544 and fixed in #548 with a runtime
workaround that deletes the incomplete window stub. The fix has been verified
working with this page deployment.

Note: This page dynamically queries AirTable on each request. It should probably
be prerendered (static) in the future to avoid unnecessary load on AirTable,
as our key staff don't change frequently. However, it served as a valuable test
case for edge function fixes, so merging as-is for now.

Original work by @Pato-desu
Fixes: #538, #540
Related: #544, #548
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants