Skip to content

JavaScriptEngineSwitcher crashes in a dockerized .NET Core application #27

Closed
@omg-a-bear

Description

@omg-a-bear

I'm pre-rendering some javascript server side in a current project, using ReactJS.NET which in turn relies heavily on JavaScriptEngineSwitcher.

Running the project from a host OS, I have no problems what so ever. I'm using ChakraCore as the engine to pre-render my React components, and I have NuGet references for the following dependencies:

- JavaScriptEngineSwitcher.ChakraCore
- JavaScriptEngineSwitcher.ChakraCore.Native.debian-x64
- JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64
- JavaScriptEngineSwitcher.ChakraCore.Native.win-x64

Running the project with dotnet run succeeds in Windows, Mac OS X and Ubuntu/Debian. Publishing the application and running it from the publish directory succeeds in all operating systems as well (using dotnet publish -c Release -o <MYPATH> && cd <MYPATH> && dotnet <DLLFILE>).

However, when creating a Docker container from my published files and running the application from a container (using base image microsoft/aspnetcore:1.1.1) I get the following exception (runtime, on first page load):

React.TinyIoC.TinyIoCResolutionException: Unable to resolve type: React.ReactEnvironment ---> React.TinyIoC.TinyIoCResolutionException: Unable to resolve type: React.JavaScriptEngineFactory ---> React.Exceptions.VroomJsInitialisationException: Failed to initialise VroomJs. This is most likely caused by the native library (libVroomJsNative.so) being out of date or your system lacking a compatible version of V8.

It seems like ChakraCore isn't registered as my default engine, or .NET Core can't find the library file? I register ChakraCore as my default javascript engine using;

services.AddJsEngineSwitcher(options =>
    options.DefaultEngineName = ChakraCoreJsEngine.EngineName
).AddChakraCore();

I've even tried using a ChakraCore binary (libChakraCore.so) compiled in my Docker image, but without success. Is there anything I'm missing, or is it something I'm missing in my setup?

I realize the problem might lie in ReactJS.NET as well - but since the main problem seems to be that the default engine isn't initialized I'm guessing it has something to do with JavaScriptEngineSwitcher.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions