Skip to content

🐛 add null check for csrf element content#459

Merged
hayleigh-dot-dev merged 1 commit into
lustre-labs:mainfrom
parrotmac:nullcheck-csrf
Apr 2, 2026
Merged

🐛 add null check for csrf element content#459
hayleigh-dot-dev merged 1 commit into
lustre-labs:mainfrom
parrotmac:nullcheck-csrf

Conversation

@parrotmac
Copy link
Copy Markdown
Contributor

Issue

On a fresh clone of the lustre repo, when running e.g. examples/06-server-components/05-publish-subscribe (also happening on at least 06-/{04-,06-}) the following is thrown in the browser console:

Uncaught TypeError: Cannot read properties of null (reading 'getAttribute')
    at #m (runtime.mjs:2:10316)
    at de.attributeChangedCallback (runtime.mjs:2:7806)
    at runtime.mjs:2:13482

This appears to happen if the csrf meta element isn't found, so meta is null here.

Fix

Added ONLY optional chaining to src/lustre/runtime/client/server_component.ffi.mjs, then ran gleam run -m build, resulting in all other changes present.


Validating this fix also required updating mist to >= v6.0.0, though that appears to be a separate issue.

Comment on lines -699 to -702
} else if (this.#route.protocol == "wss:") {
this.#route.protocol = "https:";
} else if (this.#route.protocol == "ws:") {
this.#route.protocol = "http:";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should the build process have removed these lines? Or did I mess something up?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ah yeah that's fine. The server component runtime is built fresh on every release so the releases are never out of sync but between releases sometimes we forget to run the build and commit the artefact. It's kinda an awkward dance at the moment, but yeah this change is expected don't worry!

@hayleigh-dot-dev
Copy link
Copy Markdown
Collaborator

Oh thank you, that was a silly mistake. Good catch! 💕

@hayleigh-dot-dev hayleigh-dot-dev merged commit b5ea351 into lustre-labs:main Apr 2, 2026
1 check passed
@parrotmac parrotmac deleted the nullcheck-csrf branch April 2, 2026 17:13
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

Successfully merging this pull request may close these issues.

2 participants