pentacent / keila

Open Source Newsletter Tool.
https://keila.io
GNU Affero General Public License v3.0
1.44k stars 81 forks source link

JavaScript Errors when deploying 0.14 #269

Closed kevmodrome closed 9 months ago

kevmodrome commented 9 months ago

I've recently tried deploying 0.14 and I'm running into JS errors that stops me from, among other things, importing contacts. On all the tabbed interfaces all tabs are shown at the same time. Trying 0.13.1 it works as expected.

Here's the docker-compose I'm using:

version: '3'
services:
  keila:
    image: 'pentacent/keila:latest'
    ports:
      - '19998:4000'
    depends_on:
      - postgres
    environment:
      SECRET_KEY_BASE: '${SECRET_KEY}'
      DB_URL: 'postgres://postgres:postgres@postgres/postgres'
      URL_HOST: '${URL_HOST}'
      MAILER_SMTP_HOST: '${MAILER_SMTP_HOST}'
      MAILER_SMTP_USER: '${MAILER_SMTP_USER}'
      MAILER_SMTP_PASSWORD: '${MAILER_SMTP_PASSWORD}'
  postgres:
    image: 'postgres:alpine'
    ports:
      - '5432:5432'
    environment:
      POSTGRES_PASSWORD: postgres
wmnnd commented 9 months ago

Hey there, thanks for reporting this. Could you share the errors you’re seeing?

kevmodrome commented 9 months ago

Went back and took another look. Looks like it must've been a fluke.

kevmodrome commented 9 months ago

This started happening again.

Here's what the error says: SyntaxError: No identifiers allowed directly after numeric literal and In order to be iterable, non-array objects must have a [Symbol.iterator]() method..

Here's an error that shows up when you try to sort the contacts:

2024-02-07T21:49:28.597610800Z Request: POST /projects/np_weLJnLY5/contacts
2024-02-07T21:49:28.597612603Z ** (exit) an exception was raised:
2024-02-07T21:49:28.597614236Z     ** (CaseClauseError) no case clause matching: nil
2024-02-07T21:49:28.597616260Z         (keila 0.14.0) lib/keila_web/controllers/contact_controller.ex:111: KeilaWeb.ContactController.delete/2
2024-02-07T21:49:28.597617963Z         (keila 0.14.0) lib/keila_web/controllers/contact_controller.ex:1: KeilaWeb.ContactController.action/2
2024-02-07T21:49:28.597619627Z         (keila 0.14.0) lib/keila_web/controllers/contact_controller.ex:1: KeilaWeb.ContactController.phoenix_controller_pipeline/2
2024-02-07T21:49:28.597621320Z         (phoenix 1.6.11) lib/phoenix/router.ex:354: Phoenix.Router.__call__/2
2024-02-07T21:49:28.597622993Z         (keila 0.14.0) lib/keila_web/endpoint.ex:1: KeilaWeb.Endpoint.plug_builder_call/2
2024-02-07T21:49:28.597624616Z         (keila 0.14.0) lib/keila_web/endpoint.ex:1: KeilaWeb.Endpoint.call/2
2024-02-07T21:49:28.597626239Z         (phoenix 1.6.11) lib/phoenix/endpoint/cowboy2_handler.ex:54: Phoenix.Endpoint.Cowboy2Handler.init/4
2024-02-07T21:49:28.597627872Z         (cowboy 2.10.0) /deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2

And here's an example of the tab behaviour that I mentioned before: CleanShot 2024-02-07 at 22 52 38@2x

wmnnd commented 9 months ago

Okay, these are some very distinct issues that probably don’t have anything to do with each other.

The snippet you’ve posted doesn’t seem to be from sorting contacts but rather from trying to delete contacts. Could you describe what exactly you were doing? Did you maybe click the "Delete all selected contacts" button when you didn’t have any contacts selected? That bug was reported in #260 :blush:

The issue on the import page does look like a JavaScript issue. Does it still happen when you reload the page? Could you share the output of the browser’s JavaScript console?

kevmodrome commented 9 months ago

Right. So I'm not clicking the delete button. I am just clicking the arrow next to the Added column header: CleanShot 2024-02-08 at 08 01 24@2x

This results in the following error (I just checked again):

2024-02-08T07:00:16.695269506Z 07:00:16.694 [error] #PID<0.8183.0> running KeilaWeb.Endpoint (connection #PID<0.8179.0>, stream id 2) terminated
2024-02-08T07:00:16.695293281Z Server: marketing.sveltesociety.dev:80 (http)
2024-02-08T07:00:16.695303761Z Request: POST /projects/np_weLJnLY5/contacts
2024-02-08T07:00:16.695312859Z ** (exit) an exception was raised:
2024-02-08T07:00:16.695319792Z     ** (CaseClauseError) no case clause matching: nil
2024-02-08T07:00:16.695326425Z         (keila 0.14.0) lib/keila_web/controllers/contact_controller.ex:111: KeilaWeb.ContactController.delete/2
2024-02-08T07:00:16.695331414Z         (keila 0.14.0) lib/keila_web/controllers/contact_controller.ex:1: KeilaWeb.ContactController.action/2
2024-02-08T07:00:16.695336664Z         (keila 0.14.0) lib/keila_web/controllers/contact_controller.ex:1: KeilaWeb.ContactController.phoenix_controller_pipeline/2
2024-02-08T07:00:16.695341784Z         (phoenix 1.6.11) lib/phoenix/router.ex:354: Phoenix.Router.__call__/2
2024-02-08T07:00:16.695346473Z         (keila 0.14.0) lib/keila_web/endpoint.ex:1: KeilaWeb.Endpoint.plug_builder_call/2
2024-02-08T07:00:16.695351192Z         (keila 0.14.0) lib/keila_web/endpoint.ex:1: KeilaWeb.Endpoint.call/2
2024-02-08T07:00:16.695356051Z         (phoenix 1.6.11) lib/phoenix/endpoint/cowboy2_handler.ex:54: Phoenix.Endpoint.Cowboy2Handler.init/4
2024-02-08T07:00:16.695378644Z         (cowboy 2.10.0) /deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2

The errors I posted were from the console (Safari). I logged in again and checked in another browser (Chrome): Uncaught SyntaxError: Invalid or unexpected token after logging in. When clicking the arrow: ´POST https://marketing.sveltesociety.dev/projects/np_weLJnLY5/contacts 500 (Internal Server Error)`. I have a HAR file (with passwords removed) that I can send you if that helps.

wmnnd commented 9 months ago

Now I understand what’s going on here. Somehow the JS is failing to load and clicking the sort buttons causes the delete form to be submitted. It seems like JavaScript is not working at all on your installation. Is there any chance you’ve blocked it somehow? Does the network inspector in your browser show the JS file being loaded?

I’ve also compared the JS at https://marketing.sveltesociety.dev/js/app.js with the one at https://app.keila.io/js/app.js and they’re identical.

kevmodrome commented 9 months ago

I'm now looking again and I'm not getting any errors. Everything works as it should! Super odd! No errors in the console, etc. 🤔

I run it behind a Cloudflare Tunnel, maybe that affects things? Or is it dependent on the time of day (that would be even more strange)

wmnnd commented 9 months ago

My suspicion is that some external factor kept the JS from being loaded and that caused the problem you were having. So I will close this issue for now, but feel free to reopen if it happens again!

Also, this motivated me to fix #260 and even if JS fails in future versions, you won’t get that error anymore. :blush:

kevmodrome commented 9 months ago

All right! THanks! Sorry I couldn't get you a better repro. Will keep an eye on it and see if it happens again! :)