njs: failed to create js VM

Hey, I run into issues regarding the example njs config and nginx build from source (for a container image) and hope for someone to give me a hint what / where I might be missing something.

The error message, on container start:

nginx    | 2022/09/07 22:14:55 [emerg] 1#1: failed to create js VM
nginx    | nginx: [emerg] failed to create js VM

The build config: Dockerfile The runtime config: njs git test branch commit

The error message shows as soon as js_import http.js; is added into the http block in nginx.conf.

I’ve already looked at #57 and #18 but don’t see how this would apply here.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @compilenix,

I stripped additional modules, and simplified build script

Dockerfile.574

docker build --build-arg BUSYBOX_VERSION="1.34.1" \
             --build-arg ALPINE_VERSION="3.16.1" \
             --build-arg NGINX_VERSION="1.23.1" \
             --build-arg NGINX_COMMIT=a63d0a70afea \
             --build-arg NJS_COMMIT=461dfb0bb60e \
             -f Dockerfile.574 .

This way, nginx/njs works as expected (no failed to create js VM).

So, If I were you, I would start adding everything else back by chunks and see the result.

My guess the problem is related to one of the following:

  1. PCRE lib (you are building from source all the dependencies but not libpcre2, at the same time you provide -static to the linker)
  2. OpenSSL lib
  3. CFLAGS and LDFLAGS compatibility of built libraries and nginx (--with-ld-opt="-s -static"?)