Vapid server crashes when using "unfurl"
Describe the bug
Tried to add a new YouTube video link using the unfurl=true option, and the server crashes as soon as I try to load the page rendering that link.
<div class="container">
{{video type=link unfurl=true label="Tour Video"}}
</div>
Server Error:
events.js:167
throw er; // Unhandled 'error' event
^
Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
at doWrite (_stream_writable.js:406:19)
at clearBuffer (_stream_writable.js:540:7)
at onwrite (_stream_writable.js:465:7)
at Gunzip.afterTransform (_stream_transform.js:94:3)
at Zlib.processCallback (zlib.js:619:8)
Emitted 'error' event at:
at onwriteError (_stream_writable.js:425:12)
at onwrite (_stream_writable.js:456:5)
at doWrite (_stream_writable.js:406:11)
at clearBuffer (_stream_writable.js:540:7)
[... lines matching original stack trace ...]
at Zlib.processCallback (zlib.js:619:8)
To Reproduce Steps to reproduce the behavior:
- Add a link like
{{mylink type=link unfurl=true}}to your template - Go to the dashboard, set the link to
https://www.youtube.com/watch?v=dQw4w9WgXcQ - Hit the "View" button to go back to the homepage
- See error above in Terminal
Expected behavior A YouTube embedded video should appear.
Your Environment Include relevant details, so others can replicate the issue.
- OS: Mac OS X 10.14.3
- Browser: Chrome
- Node Version: v10.14.1
- Vapid Version: v0.7.7
@lsanwick Strange. I'm running a fairly similar setup, but can't seem to replicate it:
- OS: Mac OS X 10.13.6
- Browser: Chrome
- Node Version: v10.14.1
- Vapid Version: v0.8.1
I don't think it should matter, but can you try updating to Vapid v0.8.1?
Upgrading to latest (0.9.5) didn't fix the issue for me.
I'm getting around it for now by pasting an embed code into a type=text field and then using this to unescape it:
<script>
function htmlDecode(input){
var e = document.createElement('textarea');
e.innerHTML = input;
// handle case of empty input
return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
}
var videos = document.querySelectorAll('.responsive-video');
videos.forEach(v => {
v.innerHTML = htmlDecode(v.innerHTML);
});
</script>