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

Client-side error only in release mode on 0.6.0-alpha.2: Uncaught TypeError: root is undefined / Cannot read properties of undefined (reading 'appendChild') #2926

Open
david-boles opened this issue Sep 4, 2024 · 5 comments

Comments

@david-boles
Copy link

david-boles commented Sep 4, 2024

Problem

Client-side panic when hydrating a release (not debug) fullstack build on 0.6.0-alpha.2:

Chrome:

inline0.js:2 Uncaught TypeError: Cannot read properties of undefined (reading 'appendChild')
    at RawInterpreter.appendChildren (inline0.js:2:2759)
    at RawInterpreter.run (inline0.js:148:46)
    at imports.wbg.__wbg_run_a2a42ac573bdb8ba (specs.js:723:14)
    at specs_bg.wasm:0x15e0b0
    at specs_bg.wasm:0xb5f74
    at specs_bg.wasm:0xdf35b
    at specs_bg.wasm:0x5d5ea
    at specs_bg.wasm:0x4a40c
    at specs_bg.wasm:0xdb62f
    at specs_bg.wasm:0x158ee1

Steps To Reproduce

Unsure; it doesn't happen in a new project. Will try to narrow down what's causing it in mine.

Expected behavior

No panic.

Environment:

  • Dioxus version: 0.6.0-alpha.2
  • Rust version: Probably 1.80.1? Not sure what it got installed with.
  • OS info: Ubuntu 20.04.6 LTS, 5.15.0-119-generic
  • App platform: Fullstack
@david-boles
Copy link
Author

david-boles commented Sep 5, 2024

I'm having some trouble producing a minimal reproducible example, so I think there's more playing a role here, but it seems to be related to use_server_future returning RenderError::Suspended (and me propagating that back up) on the client. Just dropping the return value from use_server_future makes this error go away. Although the initial return value from use_server_future doesn't change between release and not-release.

@david-boles
Copy link
Author

david-boles commented Sep 5, 2024

Welp, this is odd. Adding:

tokio::time::sleep(Duration::from_millis(1000)).await;

To my #[server] function being called through use_server_future fixes it. Maybe I'm hitting some sort of race condition on the client?

I notice that that does delay the final part:

<div id="ds-0-r" hidden><!--node-id0-->root<!--#--></div><script>window.dx_hydrate([0], "...")</script></body>
</html>

Getting delivered and thus hydration starting.

@david-boles david-boles changed the title Client-side panic only in release mode on 0.6.0-alpha.2: Uncaught TypeError: root is undefined / Cannot read properties of undefined (reading 'appendChild') Client-side error only in release mode on 0.6.0-alpha.2: Uncaught TypeError: root is undefined / Cannot read properties of undefined (reading 'appendChild') Sep 5, 2024
@ryo33
Copy link

ryo33 commented Nov 1, 2024

I got the same error on the latest git version, and the tokio::time::sleep(Duration::from_millis(1000)).await; trick also resolves mine.

@ryo33
Copy link

ryo33 commented Nov 1, 2024

I've created a minimum repro. https://github.com/ryo33/dioxus-repros/blob/646c6791482d1227eb69f48ac6cb0faad5d34e21/src/main.rs#L19-L40

It's just a server function that waits a milli-second. It reproduces regardless of whether suspend() is used.

@ryo33
Copy link

ryo33 commented Nov 7, 2024

It still happens on the latest "[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

2 participants