Skip to content

Conversation

lukasbachlechner
Copy link
Contributor

Changes

Following up on @ph1p's changes, we discovered our pages were suddenly failing. Example error message:

TypeError [Error]: Cannot convert undefined or null to object
      at Function.keys (<anonymous>)
      at serializeSignals (file:///Users/lukasbachlechner/development/astro/packages/astro/test/fixtures/preact-component/dist/renderers.mjs:49:44)
      at Object.renderToStaticMarkup (file:///Users/lukasbachlechner/development/astro/packages/astro/test/fixtures/preact-component/dist/renderers.mjs:146:3)
      at renderFrameworkComponent (file:///Users/lukasbachlechner/development/astro/packages/astro/test/fixtures/preact-component/dist/chunks/astro/server_B-ybt-25.mjs:1263:53)
      at async renderComponent (file:///Users/lukasbachlechner/development/astro/packages/astro/test/fixtures/preact-component/dist/chunks/astro/server_B-ybt-25.mjs:1441:10)
      at async renderChild (file:///Users/lukasbachlechner/development/astro/packages/astro/test/fixtures/preact-component/dist/chunks/astro/server_B-ybt-25.mjs:904:13) {
    id: 'src/pages/signals.astro'
  }

Turns out that we need to explicitly check if props[key] !== null because typeof null returns "object", so Object.keys(props[key]) threw this error. Added this line to the isPropObject and also added a test case for it.

Testing

Test added in astro/test/preact-component.test.js.

Docs

No user-facing changes, so none needed.

Copy link

changeset-bot bot commented Sep 5, 2024

🦋 Changeset detected

Latest commit: 3823d2c

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: preact Related to Preact (scope) pkg: integration Related to any renderer integration (scope) pkg: astro Related to the core `astro` package (scope) labels Sep 5, 2024
Copy link
Contributor

@matthewp matthewp left a comment

Choose a reason for hiding this comment

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

Wonderful, thank you!

@matthewp
Copy link
Contributor

matthewp commented Sep 5, 2024

There's a problem with our smoke tests, unrelated to your changes. Working on fixing that.

@florian-lefebvre florian-lefebvre linked an issue Sep 6, 2024 that may be closed by this pull request
1 task
@Princesseuh Princesseuh merged commit 4a44e82 into withastro:main Sep 6, 2024
11 of 13 checks passed
@lukasbachlechner lukasbachlechner deleted the fix/preact-signals-null-properties branch September 6, 2024 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) pkg: preact Related to Preact (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Passing null to a Preact component breaks the app

3 participants