denoland / fresh

The next-gen web framework.
https://fresh.deno.dev
MIT License
12.66k stars 654 forks source link

[fresh@2.0] unexpected js error with deno 2.0.1+, incorrect chunks order #2714

Open mindon opened 1 month ago

mindon commented 1 month ago
image

jsr:@fresh/core@^2.0.0-alpha.22 deno 2.0.1

TypeError: Cannot read properties of undefined (reading '__H') if built with deno 2.0.0, everything is ok

marvinhagemeister commented 1 month ago

This error occurs when multiple copies of Preact are used at the same time. Not sure yet what lead to multiple copies ending up in the esbuild bundles. Can you share the imports of the deno.json of your project?

mindon commented 1 month ago

This error occurs when multiple copies of Preact are used at the same time. Not sure yet what lead to multiple copies ending up in the esbuild bundles. Can you share the imports of the deno.json of your project?

{
  "lock": false,
  "nodeModulesDir": "auto",
  "tasks": {
    "check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
    "start": "deno run -A --unstable-kv --unstable-cron --watch=static/,routes/ dev.ts",
    "build": "deno run -A --unstable-kv --unstable-cron dev.ts build",
    "preview": "deno run -A --unstable-kv --unstable-cron --watch=static/,routes/ main.ts",
    "update": "deno run -A -r jsr:@fresh/update@2.0.0-alpha.22 ."
  },
  "lint": { "rules": { "tags": ["fresh", "recommended"] } },
  "imports": {
    "fresh": "jsr:@fresh/core@^2.0.0-alpha.22",
    "tailwindcss": "npm:tailwindcss@3.3.5",
    "@fresh/plugin-tailwind": "jsr:@fresh/plugin-tailwind@0.0.1-alpha.7",
    "$fresh_charts/": "https://deno.land/x/fresh_charts@0.3.1/",
    "$jose/": "https://deno.land/x/jose/",
    "preact": "npm:preact@^10.24.2",
    "@preact/signals": "npm:@preact/signals@^1.3.0",
    "$icons": "jsr:@preact-icons/tb",
    "@std/log": "jsr:@std/log",
    "@std/crypto": "jsr:@std/crypto",
    "@std/encoding": "jsr:@std/encoding",
    "@std/fs": "jsr:@std/fs",
  },
  "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "preact" },
  "exclude": ["**/_fresh/*", "inspection", "data", "proto"]
}
mindon commented 1 month ago

same after updating both preact and @preact/signals

    "preact": "npm:preact@^10.24.3",
    "@preact/signals": "npm:@preact/signals@^1.3.0",

the jsr:@preact-icons/tb is using jsr:@preact-icons/common which has deps npm:preact@^10.22.1

rhaldkhein commented 3 weeks ago

I'm having this issue as well. I think this only occur using Partial, when navigating a page from old build to new build.

Steps to reproduce:

  1. Run build and preview task
  2. View a page (with partial nav)
  3. Re-run build and preview task
  4. While still on the same page, navigate to another page

This happen every time when I deploy new update. My users are complaining that the website hang and couldn't click anything.

I currently suppress this error with componentDidCatch and display blank page. This way user can still trigger clicks and page navigation.

mindon commented 3 weeks ago

it seems coming from the diff of chunks, see https://github.com/denoland/deno/issues/26616#issuecomment-2451272178