mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 16:43:55 +00:00
move bundleRenderer to renderRoute with proper timeout
This commit is contained in:
parent
17d0082861
commit
a00378102b
@ -128,15 +128,6 @@ export default class Renderer extends Tapable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async render (req, res) {
|
async render (req, res) {
|
||||||
/* istanbul ignore if */
|
|
||||||
if (!this.bundleRenderer || !this.resources.appTemplate) {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
setTimeout(() => {
|
|
||||||
resolve(this.render(req, res))
|
|
||||||
}, 1000)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get context
|
// Get context
|
||||||
const context = getContext(req, res)
|
const context = getContext(req, res)
|
||||||
res.statusCode = 200
|
res.statusCode = 200
|
||||||
@ -240,7 +231,20 @@ export default class Renderer extends Tapable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async renderRoute (url, context = {}) {
|
async renderRoute (url, context = {}, ctr = 0) {
|
||||||
|
/* istanbul ignore if */
|
||||||
|
if (!this.bundleRenderer || !this.resources.appTemplate) {
|
||||||
|
if (ctr > 5) {
|
||||||
|
// Don't wait more than 5 seconds
|
||||||
|
return Promise.reject(new Error('bundleRenderer is not ready'))
|
||||||
|
}
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve(this.renderRoute(url, context, ctr++))
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Log rendered url
|
// Log rendered url
|
||||||
debug(`Rendering url ${url}`)
|
debug(`Rendering url ${url}`)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user