adamghill / django-unicorn

The magical reactive component framework for Django ✨
https://www.django-unicorn.com
MIT License
2.37k stars 120 forks source link

Get `Node.replaceChild: Argument 1 does not implement interface Node` when using action #427

Closed fl-brucele closed 2 years ago

fl-brucele commented 2 years ago

I got this error when trying to use Action inside sub-component.

TypeError: Node.replaceChild: Argument 1 does not implement interface Node.
    morphdom http://t1.localhost:8000/static/unicorn/js/morphdom/2.6.1/morphdom.js:798
    send http://t1.localhost:8000/static/unicorn/js/messageSender.js:227
    promise callback*send http://t1.localhost:8000/static/unicorn/js/messageSender.js:76
    later http://t1.localhost:8000/static/unicorn/js/delayers.js:22
    setTimeout handler*debounce/< http://t1.localhost:8000/static/unicorn/js/delayers.js:28
    queueMessage http://t1.localhost:8000/static/unicorn/js/component.js:501
    callMethod http://t1.localhost:8000/static/unicorn/js/component.js:253
    addActionEventListener http://t1.localhost:8000/static/unicorn/js/eventListeners.js:191
    addActionEventListener http://t1.localhost:8000/static/unicorn/js/eventListeners.js:110
    addActionEventListener http://t1.localhost:8000/static/unicorn/js/eventListeners.js:94
    refreshEventListeners http://t1.localhost:8000/static/unicorn/js/component.js:227
    refreshEventListeners http://t1.localhost:8000/static/unicorn/js/component.js:217
    walk http://t1.localhost:8000/static/unicorn/js/utils.js:128
    refreshEventListeners http://t1.localhost:8000/static/unicorn/js/component.js:174
    Component http://t1.localhost:8000/static/unicorn/js/component.js:56
    componentInit http://t1.localhost:8000/static/unicorn/js/unicorn.js:31
    <anonymous> http://t1.localhost:8000/product/:357
component.js:257:17
adamghill commented 2 years ago

Looks like the code that is failing is here: https://github.com/adamghill/django-unicorn/blob/main/django_unicorn/static/unicorn/js/messageSender.js#L227-L231. Maybe the sub-component root is missing for some reason? My example nested component with actions is working for me locally. Feel free to fork it to replicate what you are seeing or make a sample repo that replicates.

fl-brucele commented 2 years ago

Hi @adamghill, I didn't notice that you reply my message. I have that issue when deploying our application on EC2. I am using nginx and gunicorn to deploy the django. Also, I have followed your example too.

fl-brucele commented 2 years ago

@adamghill nvm. I found the root cause. It's about using cache with redis instead.