Skip to content

Commit

Permalink
Merge pull request #5 from knopki/fix-dont-wait-timeout
Browse files Browse the repository at this point in the history
fix: don't wait stale timeout
  • Loading branch information
jakobrosenberg authored Oct 1, 2020
2 parents 2f4af03 + 6dacc54 commit f79c3e6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ module.exports.ssr = async function ssr(template, script, url, options) {

if (eventName) {
dom.window.addEventListener(eventName, resolveHtml)
setTimeout(() => {
const eventTimeout = setTimeout(() => {
if (dom.window._document) {
console.log(`${url} timedout after ${timeout} ms`);
resolveHtml()
}
}, timeout)
dom.window.addEventListener(
eventName,
() => clearTimeout(eventTimeout)
)
}
await beforeEval(dom)
if (meta) setMeta(dom, meta)
Expand Down

0 comments on commit f79c3e6

Please sign in to comment.