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

getting a Cannot read properties of null (reading 'rawAttrs') error #1353

Closed
thescientist13 opened this issue Dec 21, 2024 · 1 comment · Fixed by #1360
Closed

getting a Cannot read properties of null (reading 'rawAttrs') error #1353

thescientist13 opened this issue Dec 21, 2024 · 1 comment · Fixed by #1360
Assignees
Labels
alpha.2 bug Something isn't working CLI v0.31.0
Milestone

Comments

@thescientist13
Copy link
Member

Type of Change

Bug

Summary

In this project it was observed that at times this line in Greenwood would fail in this project

TypeError: Cannot read properties of null (reading 'rawAttrs')
    at getAppLayout (file:///Users/owenbuckley/Workspace/github-forks/HP_Stuff/node_modules/.pnpm/@[email protected]_patch_hash=pkl2llrpdlpyhjjur27kchnsuq/node_modules/@greenwood/cli/src/lib/layout-utils.js:221:66)
    at async StandardHtmlResource.serve (file:///Users/owenbuckley/Workspace/github-forks/HP_Stuff/node_modules/.pnpm/@[email protected]_patch_hash=pkl2llrpdlpyhjjur27kchnsuq/node_modules/@greenwood/cli/src/plugins/resource/plugin-standard-html.js:125:12)
    at async file:///Users/owenbuckley/Workspace/github-forks/HP_Stuff/node_modules/.pnpm/@[email protected]_patch_hash=pkl2llrpdlpyhjjur27kchnsuq/node_modules/@greenwood/cli/src/lifecycles/serve.js:69:27
    at async file:///Users/owenbuckley/Workspace/github-forks/HP_Stuff/node_modules/.pnpm/@[email protected]_patch_hash=pkl2llrpdlpyhjjur27kchnsuq/node_modules/@greenwood/cli/src/lifecycles/serve.js:55:5

Details

Not really sure why so will need to play around with exactly why to find a reproduction case, but this simple fix seemed to work at least

const mergedHtml = pageRoot && pageRoot.querySelector('html')?.rawAttrs
  ? `<html ${pageRoot.querySelector('html').rawAttrs}>`
  : appRoot.querySelector('html').rawAttrs !== ''
    ? `<html ${appRoot.querySelector('html').rawAttrs}>`
    '<html>';

All the pages in question seemed to have an <html> tag though?

@thescientist13 thescientist13 added bug Something isn't working CLI v0.31.0 labels Dec 21, 2024
@thescientist13 thescientist13 added this to the 1.0 milestone Dec 21, 2024
@thescientist13 thescientist13 self-assigned this Dec 21, 2024
@thescientist13 thescientist13 changed the title getting a _Cannot read properties of null (reading 'rawAttrs')_ error getting a Cannot read properties of null (reading 'rawAttrs') error Dec 21, 2024
@thescientist13
Copy link
Member Author

So the reproduction was simply a page file with no <html> tag

<body>
  <h3>Home Page</h3>
  <p>Coffey was here</p>
</body>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alpha.2 bug Something isn't working CLI v0.31.0
Projects
1 participant