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

Regression: preact useId() does not work since @astrojs/preact@3.1.0 #9733

Closed
1 task
smnbbrv opened this issue Jan 19, 2024 · 4 comments · Fixed by #11464
Closed
1 task

Regression: preact useId() does not work since @astrojs/preact@3.1.0 #9733

smnbbrv opened this issue Jan 19, 2024 · 4 comments · Fixed by #11464
Labels
ecosystem: upstream Upstream package has issue pkg: preact Related to Preact (scope)

Comments

@smnbbrv
Copy link

smnbbrv commented Jan 19, 2024

Astro Info

Astro                    v4.2.1
Node                     v18.18.0
System                   Linux (x64)
Package Manager          unknown
Output                   static
Adapter                  none
Integrations             @astrojs/preact

If this issue only occurs in one browser, which browser is a problem?

Chrome (others I guess too)

Describe the Bug

Using useId() throws the following error:

TypeError: Cannot read properties of undefined (reading '__m')
at Module.V (file:///home/projects/withastro-astro-vob6us/node_modules/preact/hooks/dist/hooks.mjs:27:2104)
at b.Preact (/home/projects/withastro-astro-vob6us/src/components/Preact.tsx:9:36)
at e (file:///home/projects/withastro-astro-vob6us/node_modules/preact-ssr-prepass/dist/index.mjs:16:1319)
at Module.s (file:///home/projects/withastro-astro-vob6us/node_modules/preact-ssr-prepass/dist/index.mjs:16:1517)
at Object.renderToStaticMarkup (/home/projects/withastro-astro-vob6us/node_modules/@astrojs/preact/dist/server.js:67:38)
at renderFrameworkComponent (/home/projects/withastro-astro-vob6us/node_modules/astro/dist/runtime/server/render/component.js:184:68)
at async Module.renderComponent (/home/projects/withastro-astro-vob6us/node_modules/astro/dist/runtime/server/render/component.js:369:10)

What's the expected result?

Properly working useId as in ~3.0.0

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-vob6us

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jan 19, 2024
@smnbbrv smnbbrv changed the title Regression: preact useId() does not work since 3.1.0 Regression: preact useId() does not work since @astrojs/preact@3.1.0 Jan 19, 2024
@ematipico ematipico added pkg: preact Related to Preact (scope) - P4: important Violate documented behavior or significantly impacts performance (priority) and removed needs triage Issue needs to be triaged labels Jan 19, 2024
@ktym4a
Copy link
Contributor

ktym4a commented Jan 30, 2024

I place here the results of my brief research.

If I just change this (back to before #9524)

const vNode: VNode<any> = h(
Component,
newProps,
children != null
? h(StaticHtml, {
hydrate: shouldHydrate(metadata),
value: children,
})
: children
);
await prepass(vNode);
const html = render(vNode);
return { attrs, html };

to this and run it, it works correctly.

const html = render(
h(
Component,
newProps,
children != null
? h(StaticHtml, {
hydrate: shouldHydrate(metadata),
value: children,
})
: children
) as VNode<any>
);
return {
attrs,
html,
};


if I add catch, errors are not displayed on the client side in dev mode.

await prepass(vNode).catch((err) => {});

But after do HMR on the client side then reload, error displayed on the client side.

Screenshot 2024-01-30 at 17 55 41

this error is from const html = render(vNode); I think.

try {
    const html = render(vNode);
    return { attrs, html };
} catch (err) {
    console.log(err);
}

and error messages is like this.

Promise {
  <pending>,
  [Symbol(async_id_symbol)]: 119840,
  [Symbol(trigger_async_id_symbol)]: 119825,
  [Symbol(kResourceStore)]: IncomingMessage {
    ...
  }
}

I've been wanting to contribute about this isssue, but I feel like preact-ssr-prepass is the cause and now I don't know what I can do.

@natemoo-re
Copy link
Member

Thanks for looking into it @ktym4a! I think you're correct that preact-ssr-prepass is the cause. We might need to open an issue on their repository and/or get some help from the Preact team on this.

@ematipico ematipico added the ecosystem: upstream Upstream package has issue label Feb 27, 2024
@rstacruz
Copy link

Thanks for opening this as an issue in the preact-ssr-prepass repo, too! preactjs/preact-ssr-prepass#60

@ematipico ematipico removed the - P4: important Violate documented behavior or significantly impacts performance (priority) label Feb 28, 2024
birjj added a commit to birjj/jfagerberg.me that referenced this issue Mar 10, 2024
@rschristian
Copy link
Contributor

This was just fixed & is available in preact-ssr-prepass@1.2.2

birjj added a commit to birjj/jfagerberg.me that referenced this issue Jul 16, 2024
* refact(blog): stop using git submodules, and instead integrate files directly

* feat: implement new blog layout

* refact: move away from Tailwind, upgrade packages, and work on a kitchensink

Currently this build is incomplete, as I am ironing out bugs in the code after package upgrades

* fix(deps): downgrade Preact-integration to avoid regression

See withastro/astro#9733

* chore: update kitchensink to better reflect MDX capabilities

* style: avoid hyphenating words in new design

* feat: add Expressive Code support to dark mode switcher

* refact: remove Tailwind code from BaseLayout and BlogPostLayout

* refact: translate the navbar into non-Tailwind

* feat(blog): implement remainder of kitchensink elements in new typography styling

* style: change to Overpass font with slightly increased lineheight

* style: slightly rework figure and image styles in blog articles

* feat: add image to cookie compliance post

* feat: rewrite the cookie compliance blog post for the new layout

* style: move header image of cookie compliance up a bit

* fix: minor rewordings for cookie compliance

* feat: add diagrams to cookie compliance post

* feat: inline SVG diagrams for light/dark mode support

* feat: minor wording updates to cookie compliance blog

* refact: move styles around for slightly better decoupling

* refact: minor moving around of styles between layouts

* feat: fix blog page after moving away from Tailwind

* refact: update hero on landing page after moving away from Tailwind

* feat: reorder cookie compliance blog post a bit

* fix: don't scroll if browser is about to restore scroll position

* refact: rewrite landing page to not use Tailwind

* feat: add change and publish date to blog posts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ecosystem: upstream Upstream package has issue pkg: preact Related to Preact (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants