Skip to content
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

[[email protected]] unexpected js error with deno 2.0.1+, incorrect chunks order #2714

Closed
mindon opened this issue Oct 17, 2024 · 7 comments

Comments

@mindon
Copy link

mindon commented Oct 17, 2024

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
Copy link
Collaborator

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
Copy link
Author

mindon commented Oct 18, 2024

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/[email protected] ."
  },
  "lint": { "rules": { "tags": ["fresh", "recommended"] } },
  "imports": {
    "fresh": "jsr:@fresh/core@^2.0.0-alpha.22",
    "tailwindcss": "npm:[email protected]",
    "@fresh/plugin-tailwind": "jsr:@fresh/[email protected]",
    "$fresh_charts/": "https://deno.land/x/[email protected]/",
    "$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
Copy link
Author

mindon commented Oct 21, 2024

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

@mindon mindon changed the title [[email protected]] if built with deno 2.0.1, there's a js error [[email protected]] js error with deno 2.0.1+ Oct 30, 2024
@rhaldkhein
Copy link

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
Copy link
Author

mindon commented Nov 4, 2024

it seems coming from the diff of chunks, see denoland/deno#26616 (comment)

@mindon mindon changed the title [[email protected]] js error with deno 2.0.1+ [[email protected]] unexpected js error with deno 2.0.1+ with wrong chunks order Nov 12, 2024
@mindon mindon changed the title [[email protected]] unexpected js error with deno 2.0.1+ with wrong chunks order [[email protected]] unexpected js error with deno 2.0.1+, incorrect chunks order Nov 19, 2024
@mindon
Copy link
Author

mindon commented Jan 17, 2025

finally, it's gone in Deno v2.16

@mindon mindon closed this as completed Jan 17, 2025
@skinkade
Copy link

I am / was getting this issue with Deno 2.1.6 using the regular project template of Fresh 1.7.3 instantiated with:

deno run -A -r https://fresh.deno.dev

Specifically, I was getting the error when the homepage component tried to call useSignal.

Per @marvinhagemeister's comment, I ran deno info main.ts and saw the default dependency versions were bringing in multiple versions of preact and preact/signals. Bumping my versions in deno.json to the latest shown for each resolved the error.

Here's the imports from the default template with the applicable version bumps:

{
    "$fresh/": "https://deno.land/x/[email protected]/",
    "preact": "https://esm.sh/[email protected]",
    "preact/": "https://esm.sh/[email protected]/",
    "@preact/signals": "https://esm.sh/*@preact/[email protected]",
    "@preact/signals-core": "https://esm.sh/*@preact/[email protected]",
    "tailwindcss": "npm:[email protected]",
    "tailwindcss/": "npm:/[email protected]/",
    "tailwindcss/plugin": "npm:/[email protected]/plugin.js",
    "$std/": "https://deno.land/[email protected]/"
}

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

No branches or pull requests

4 participants