question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Meta errors when rendering multiple times concurrently

See original GitHub issue

Version: 1.1.3

Our company have recently converted all our emails to heml, and have been loving its simplicity so far. All of the emails we’ve sent so far have been transactional, where we’ve only sent them one at a time, and it’s worked without a hitch. We’re now implementing a monthly report for our users which will be sent out in bulk, and we’re seeing errors in development.

The error trace is as follows:

TypeError: null is not iterable!
    at module.exports.require.getIterator (/Users/admin/Documents/backend/node_modules/core-js/library/modules/core.get-iterator.js:5:42)
    at Object.flush (/Users/admin/Documents/backend/node_modules/@heml/elements/build/Meta.js:60:54)
    at _callee$ (/Users/admin/Documents/backend/node_modules/@heml/render/build/index.js:343:73)
    at tryCatch (/Users/admin/Documents/backend/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/Users/admin/Documents/backend/node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (/Users/admin/Documents/backend/node_modules/regenerator-runtime/runtime.js:114:21)
    at step (/Users/admin/Documents/backend/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/admin/Documents/backend/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13

This seems to be caused by Meta - the metaMap Map is being flushed on the first render (this line), then the null Map is causing errors in subsequent renders.

Is there a preferred method to handle rendering multiple emails concurrently, or is this a bug? Happy to provide any more information if required - otherwise I suppose the quickest fix for us would be to build the emails in series.

Thanks, Ben Mansley

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

1reaction
GemNcommented, Feb 11, 2020

I found a workaround. I actually build with a script all my folder heml, into a folder html. Push both folders and in the code I directly load from the html folder (and for variables i use Mustache)

Script to build:

#!/bin/bash
type heml >/dev/null 2>&1 || { echo >&2 "Require heml. Please install (yarn global add heml)."; exit 1; }

for entry in "heml"/*
do
  if [ -f "$entry" ];then
    echo "-- Building $entry to html"
    filename=${entry##*/}
    heml build $entry --output html/${filename%.*}.html
  fi
done

Load html email:

const htmlEmail = fs.readFileSync(`${__dirname}/../emails/templates/html/myemail.html`, {
  encoding: 'utf-8',
});

Build the emails with dynamic variables:

const htmlEmailWithValues = Mustache.render(htmlEmail, emailData);
const form = new FormData();
form.append('from', 'App <info@app.co>');
form.append('to', `${firstname} <${email}>`);
form.append('subject', subject);
form.append('html', htmlEmailWithValues);
1reaction
GemNcommented, Jul 8, 2019

Hello, Got exactly the same problems when rendering emails to send to different customers in AWS lambda

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is my component throwing a "too many re-renders" error?
This console.log with a map inside is doing many setStates at the same time, causing the UI to re-render at each "pokemon" entity...
Read more >
Stories for multiple components - Storybook - JS.ORG
Stories for multiple components. It's useful to write stories that render two or more components at once if those components are designed to...
Read more >
Hooks FAQ - React
Should I use Hooks, classes, or a mix of both? Do Hooks cover all use cases for classes? Do Hooks replace render props...
Read more >
Cycles Metal crash with simultaneous viewport and final render
Worked: none (testing the new Metal renderer). Short description of error. Blender crashes when using Cycles with Metal GPU in both viewport and...
Read more >
How to solve too many re-renders error in ReactJS?
“Too many re-renderers” is a React error that happens after you have reached an infinite render loop, typically caused by code that in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found