Skip to content

Commit

Permalink
Update JavaScript evaluator and enable caching
Browse files Browse the repository at this point in the history
Removed unused imports in JavaScript evaluator and instantiated ObjectWrapper using static Create method. This simplifies the object instantiation process. Additionally, updated the mediator reference and activated the useCaching feature on the Elsa server to optimize performance.
  • Loading branch information
sfmskywalker committed Jun 15, 2024
1 parent 72c3d2c commit 74fc0c9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/bundles/Elsa.Server.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
const bool useZipCompression = false;
const bool runEFCoreMigrations = true;
const bool useMemoryStores = false;
const bool useCaching = false;
const bool useCaching = true;
const bool useAzureServiceBusModule = false;
const bool useReadOnlyMode = false;
const WorkflowRuntime workflowRuntime = WorkflowRuntime.ProtoActor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
using Elsa.Mediator.Contracts;
using Humanizer;
using Jint;
using Jint.Native;
using Jint.Native.TypedArray;
using Jint.Runtime.Interop;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
Expand Down Expand Up @@ -63,7 +61,7 @@ private async Task<Engine> GetConfiguredEngine(Action<Engine>? configureEngine,
// Wrap objects in ObjectWrapper instances and set their prototype to Array.prototype if they are array-like.
engineOptions.SetWrapObjectHandler((engine, target, type) =>
{
var instance = new ObjectWrapper(engine, target);
var instance = ObjectWrapper.Create(engine, target);
if (ObjectArrayHelper.DetermineIfObjectIsArrayLikeClrCollection(target.GetType()))
instance.Prototype = engine.Intrinsics.Array.PrototypeObject;
Expand All @@ -73,7 +71,7 @@ private async Task<Engine> GetConfiguredEngine(Action<Engine>? configureEngine,

engineOptions.Interop.ObjectConverters.Add(new ByteArrayConverter());

await _mediator.SendAsync(new CreatingJavaScriptEngine(engineOptions, context), cancellationToken);
await mediator.SendAsync(new CreatingJavaScriptEngine(engineOptions, context), cancellationToken);
var engine = new Engine(engineOptions);

configureEngine?.Invoke(engine);
Expand Down

0 comments on commit 74fc0c9

Please sign in to comment.