Mailtrain-org / mailtrain

Self hosted newsletter app
GNU General Public License v3.0
5.52k stars 692 forks source link

Cannot read property 'mjml' of null #338

Closed danilobuerger closed 3 years ago

danilobuerger commented 7 years ago

Version: https://github.com/Mailtrain-org/mailtrain/commit/615ed5a693afd9ab78e7d84909fb18d8bdf4109b Node: 8.6.0

When editing a Grapejs / MJML Template, I sometimes get this error message and mailtrain crashes:

/srv/node_modules/mysql/lib/protocol/Parser.js:80
throw err; // Rethrow non-MySQL errors
^
TypeError: Cannot read property 'mjml' of null
at editorHelpers.getResource (/srv/node_modules/mailtrain/routes/grapejs.js:62:46)
at getMergeTagsForResource (/srv/node_modules/mailtrain/lib/editor-helpers.js:26:24)
at helpers.getDefaultMergeTags (/srv/node_modules/mailtrain/lib/editor-helpers.js:58:20)
at Object.getDefaultMergeTags (/srv/node_modules/mailtrain/lib/helpers.js:31:5)
at getMergeTagsForResource (/srv/node_modules/mailtrain/lib/editor-helpers.js:52:13)
at templates.get (/srv/node_modules/mailtrain/lib/editor-helpers.js:20:13)
at Query.connection.query [as _callback] (/srv/node_modules/mailtrain/lib/models/templates.js:45:20)
at Query.Sequence.end (/srv/node_modules/mysql/lib/protocol/sequences/Sequence.js:88:24)
at Query._handleFinalResultPacket (/srv/node_modules/mysql/lib/protocol/sequences/Query.js:139:8)
at Query.EofPacket (/srv/node_modules/mysql/lib/protocol/sequences/Query.js:123:8)

I am not sure how to consistently reproduce this yet. It happens when I edit a template, accidentally swipe on my touchpad to the right so that Chrome goes back. As soon as I try to go back in the template, it crashes on clicking "Open GrapeJS".

witzig commented 7 years ago

I tried all kind of things but wasn't able to reproduce this error so far.

danilobuerger commented 7 years ago

@witzig I believe it has to do with a specific template. It only every crashes with this one:

mysql> select * from templates where id = 18;
+----+-----------------------------+-------------+-------------+-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+
| id | name                        | description | editor_name | editor_data | html                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | text                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | created             |
+----+-----------------------------+-------------+-------------+-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+
| 18 | Erneuter Bonus GrapeJS mjml |             | grapejs     | NULL        | <!doctype html>
<html>

<head>
    <meta charset="utf-8">
</head>

<body>

    <p>Hey [FIRST_NAME/Customer],</p>

    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed varius, leo a ullamcorper feugiat, ante purus sodales justo, a faucibus libero lacus a est.</p>

    <p>Sed varius, leo a ullamcorper feugiat, ante purus sodales justo, a faucibus libero lacus a est. Aenean at mollis ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed varius, leo a ullamcorper feugiat, ante purus sodales justo, a faucibus
        libero lacus a est.</p>

    <p>Cheers,
        <br/> feastr Dev
    </p>
    <p>
        feastr GmbH, Gustav-Heinemann-Str. 96, 86199 Augsburg
        <br/>
        <a href="[LINK_PREFERENCES]" style="color: #666666; text-decoration: none;">Preferences</a>
        <span style="color: #444444;">&nbsp;&nbsp;|&nbsp;&nbsp;</span>
        <a href="[LINK_UNSUBSCRIBE]" style="color: #666666; text-decoration: none;">Unsubscribe</a>
        <span style="color: #444444;">&nbsp;&nbsp;|&nbsp;&nbsp;</span>
        <a href="[LINK_BROWSER]" style="color: #666666; text-decoration: none;">View this email in your browser</a>
    </p>

</body>

</html> | Hey [FIRST_NAME/Customer],

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed varius, leo a ullamcorper feugiat, ante purus sodales justo, a faucibus libero lacus a est.

Sed varius, leo a ullamcorper feugiat, ante purus sodales justo, a faucibus libero lacus a est. Aenean at mollis ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed varius, leo a ullamcorper feugiat, ante purus sodales justo, a faucibus libero lacus a est.

Cheers,
feastr Dev

feastr GmbH, Gustav-Heinemann-Str. 96, 86199 Augsburg

Preferences: [LINK_PREFERENCES]
Unsubscribe: [LINK_UNSUBSCRIBE]
View this email in your browser: [LINK_BROWSER] | 2017-10-09 17:33:28 |
+----+-----------------------------+-------------+-------------+-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+
1 row in set (0.07 sec)
jorgepg17 commented 4 years ago

Did you solve the problem? The same happens to me in a template TypeError: Cannot read property 'mjml' of null

talheim-it commented 3 years ago

@jorgepg17 can you please test with latest v2 and open a new issues with all infos about deployment (docker or directly on which os, configuration and log files)? Thanks!