Comparing version 3.0.0 to 3.0.1
@@ -0,1 +1,6 @@ | ||
## v3.0.1 (2020-03-12) | ||
#### :rocket: Enhancement | ||
* [#262](https://github.com/ember-fastboot/fastboot/pull/262) Improve performance when using new sandbox per visit by building sandbox after the request ([@kratiahuja](https://github.com/kratiahuja)) | ||
## v3.0.0 (2020-01-31) | ||
@@ -2,0 +7,0 @@ |
{ | ||
"name": "fastboot", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Library for rendering Ember apps in node.js", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -192,2 +192,12 @@ 'use strict'; | ||
/** | ||
* Builds a new application instance sandbox as a micro-task. | ||
*/ | ||
buildNewApplicationInstance() { | ||
return Promise.resolve().then(() => { | ||
let app = this.buildApp(); | ||
return app; | ||
}); | ||
} | ||
/** | ||
* @private | ||
@@ -234,2 +244,25 @@ * | ||
* | ||
* Get the new sandbox off if it is being created, otherwise create a new one on demand. | ||
* The later is needed when the current request hasn't finished or wasn't build with sandbox | ||
* per request turned on and a new request comes in. | ||
* | ||
*/ | ||
async _getNewApplicationInstance() { | ||
let app; | ||
if (this._pendingNewApplicationInstance) { | ||
let pendingAppInstancePromise = this._pendingNewApplicationInstance; | ||
this._pendingNewApplicationInstance = undefined; | ||
app = await pendingAppInstancePromise; | ||
} else { | ||
// if there is no current pending application instance, create a new one on-demand. | ||
app = await this.buildApp(); | ||
} | ||
return app; | ||
} | ||
/** | ||
* @private | ||
* | ||
* Main function that creates the app instance for every `visit` request, boots | ||
@@ -257,3 +290,3 @@ * the app instance and then visits the given route and destroys the app instance | ||
let app = shouldBuildApp ? await this.buildApp() : this._applicationInstance; | ||
let app = shouldBuildApp ? await this._getNewApplicationInstance() : this._applicationInstance; | ||
@@ -311,2 +344,3 @@ if (buildSandboxPerVisit) { | ||
let destroyAppInstanceInMs = parseInt(options.destroyAppInstanceInMs, 10); | ||
let buildSandboxPerVisit = options.buildSandboxPerVisit || false; | ||
@@ -338,9 +372,3 @@ let shouldRender = options.shouldRender !== undefined ? options.shouldRender : true; | ||
try { | ||
await this._visit( | ||
path, | ||
fastbootInfo, | ||
bootOptions, | ||
result, | ||
options.buildSandboxPerVisit === true | ||
); | ||
await this._visit(path, fastbootInfo, bootOptions, result, buildSandboxPerVisit); | ||
@@ -363,2 +391,8 @@ if (!disableShoebox) { | ||
clearTimeout(destroyAppInstanceTimer); | ||
if (buildSandboxPerVisit) { | ||
// if sandbox was built for this visit, then build a new sandbox for the next incoming request | ||
// which is invoked using buildSandboxPerVisit | ||
this._pendingNewApplicationInstance = this.buildNewApplicationInstance(); | ||
} | ||
} | ||
@@ -365,0 +399,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1227
73968
22