diff --git a/.github/workflows/test-and-build-quickjs.yml b/.github/workflows/test-and-build-quickjs.yml index e645402e1..816a29e35 100644 --- a/.github/workflows/test-and-build-quickjs.yml +++ b/.github/workflows/test-and-build-quickjs.yml @@ -10,6 +10,7 @@ on: jobs: metadata: name: metadata + if: ${{ false }} runs-on: ubuntu-latest outputs: edge_version: ${{ steps.version.outputs.edge_version }} @@ -41,6 +42,7 @@ jobs: quickjs-linux: name: quickjs-linux + if: ${{ false }} runs-on: ubuntu-latest env: SCCACHE_GHA_ENABLED: "true" @@ -60,7 +62,19 @@ jobs: set -euo pipefail git submodule sync --recursive git -c protocol.version=2 submodule update --init --recursive --depth=1 - test -f node/src/node_api_types.h + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" + + - name: Enable pnpm + shell: bash + run: | + set -euo pipefail + corepack enable + corepack prepare pnpm@latest --activate + pnpm --version - name: Install Linux build dependencies shell: bash @@ -100,12 +114,25 @@ jobs: set -euo pipefail make test-quickjs-only TEST_JOBS=4 + - name: Test framework apps (QuickJS native) + shell: bash + run: | + set -euo pipefail + make framework-test-quickjs-native + + - name: Test standalone builds (QuickJS native) + shell: bash + run: | + set -euo pipefail + make standalone-build-test-quickjs-native + - name: sccache stats if: always() run: sccache --show-stats || true quickjs-macos: name: quickjs-macos + if: ${{ false }} runs-on: macos-latest env: SCCACHE_GHA_ENABLED: "true" @@ -125,7 +152,19 @@ jobs: set -euo pipefail git submodule sync --recursive git -c protocol.version=2 submodule update --init --recursive --depth=1 - test -f node/src/node_api_types.h + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" + + - name: Enable pnpm + shell: bash + run: | + set -euo pipefail + corepack enable + corepack prepare pnpm@latest --activate + pnpm --version - name: Validate public N-API headers stay V8-agnostic shell: bash @@ -140,12 +179,14 @@ jobs: make build-edge-quickjs-cli CMAKE_BUILD_TYPE=Release JOBS=4 - name: Generate dist + if: ${{ false }} shell: bash run: | set -euo pipefail make dist-only BUILD_DIR=build-edge-quickjs-cli JOBS=4 ZIP_NAME=edge-quickjs-darwin-arm64.zip - name: Upload artifact edge + if: ${{ false }} uses: actions/upload-artifact@v4 with: name: edge-quickjs-darwin-arm64 @@ -158,6 +199,18 @@ jobs: set -euo pipefail make test-quickjs-only TEST_JOBS=4 + - name: Test framework apps (QuickJS native) + shell: bash + run: | + set -euo pipefail + make framework-test-quickjs-native + + - name: Test standalone builds (QuickJS native) + shell: bash + run: | + set -euo pipefail + make standalone-build-test-quickjs-native + - name: sccache stats if: always() run: sccache --show-stats || true @@ -170,12 +223,32 @@ jobs: with: submodules: recursive + - name: Ensure submodules are initialized + shell: bash + run: | + set -euo pipefail + git submodule sync --recursive + git -c protocol.version=2 submodule update --init --recursive --depth=1 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" + + - name: Enable pnpm + shell: bash + run: | + set -euo pipefail + corepack enable + corepack prepare pnpm@latest --activate + pnpm --version + - name: Install wasixcc - uses: wasix-org/wasixcc@v0.4.2 + uses: wasix-org/wasixcc@v0.4.3 with: github_token: ${{ secrets.GITHUB_TOKEN }} - sysroot-tag: v2026-02-16.1 - version: v0.4.2 + sysroot-tag: v2026-06-25.1 + version: v0.4.3 - name: Build edge (QuickJS WASIX) shell: bash @@ -183,7 +256,34 @@ jobs: set -euo pipefail make build-quickjs-wasix + - name: Install Wasmer CLI + shell: bash + run: | + set -euo pipefail + curl https://get.wasmer.io -sSfL | sh -s "v7.2.0-rc.1" + echo "${HOME}/.wasmer/bin" >> "${GITHUB_PATH}" + "${HOME}/.wasmer/bin/wasmer" --version + + - name: Test edge (QuickJS WASIX) + shell: bash + run: | + set -euo pipefail + make test-wasix-quickjs-only TEST_JOBS=1 + + - name: Test framework apps (QuickJS WASIX) + shell: bash + run: | + set -euo pipefail + make framework-test-quickjs-wasix + + - name: Test standalone builds (QuickJS WASIX) + shell: bash + run: | + set -euo pipefail + make standalone-build-test-quickjs-wasix + - name: Generate dist + if: ${{ false }} shell: bash run: | set -euo pipefail @@ -194,6 +294,7 @@ jobs: (cd dist && zip -r ../edge-quickjs-wasix.zip bin bin-compat README.md wasmer.toml ssl-certs) - name: Upload artifact edge + if: ${{ false }} uses: actions/upload-artifact@v4 with: name: edge-quickjs-wasix @@ -202,13 +303,13 @@ jobs: publish-nightly: name: publish-nightly + if: ${{ false }} runs-on: ubuntu-latest needs: - metadata - quickjs-linux - quickjs-macos - quickjs-wasix - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} env: GH_TOKEN: ${{ secrets.RELEASE_PLEASE_GH_TOKEN }} TARGET_REPO: wasmerio/edgejs-nightlies @@ -350,7 +451,12 @@ jobs: "${files[@]}" - name: Install Wasmer CLI - uses: wasmerio/setup-wasmer@v3 + shell: bash + run: | + set -euo pipefail + curl https://get.wasmer.io -sSfL | sh -s "v7.2.0-rc.1" + echo "${HOME}/.wasmer/bin" >> "${GITHUB_PATH}" + "${HOME}/.wasmer/bin/wasmer" --version - name: Publish to wasmer.wtf env: diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml index 8fc342fb5..2c9709810 100644 --- a/.github/workflows/test-and-build.yml +++ b/.github/workflows/test-and-build.yml @@ -10,6 +10,7 @@ on: jobs: metadata: name: metadata + if: ${{ false }} runs-on: ubuntu-latest outputs: edge_version: ${{ steps.version.outputs.edge_version }} @@ -41,6 +42,7 @@ jobs: v8-linux: name: v8-linux + if: ${{ false }} runs-on: ubuntu-latest env: NAPI_V8_BUILD_METHOD: prebuilt @@ -61,7 +63,6 @@ jobs: set -euo pipefail git submodule sync --recursive git -c protocol.version=2 submodule update --init --recursive --depth=1 - test -f node/src/node_api_types.h - name: Install Linux build dependencies shell: bash @@ -107,6 +108,7 @@ jobs: v8-macos: name: v8-macos + if: ${{ false }} runs-on: macos-latest env: NAPI_V8_BUILD_METHOD: prebuilt @@ -127,7 +129,6 @@ jobs: set -euo pipefail git submodule sync --recursive git -c protocol.version=2 submodule update --init --recursive --depth=1 - test -f node/src/node_api_types.h - name: Validate public N-API headers stay V8-agnostic shell: bash @@ -166,6 +167,7 @@ jobs: v8-wasix: name: v8-wasix + if: ${{ false }} runs-on: ubuntu-latest env: SCCACHE_GHA_ENABLED: "true" @@ -182,11 +184,11 @@ jobs: uses: dtolnay/rust-toolchain@stable - name: Install wasixcc - uses: wasix-org/wasixcc@v0.4.2 + uses: wasix-org/wasixcc@v0.4.3 with: github_token: ${{ secrets.GITHUB_TOKEN }} - sysroot-tag: v2026-02-16.1 - version: v0.4.2 + sysroot-tag: v2026-06-25.1 + version: v0.4.3 - name: Install wasm-tools shell: bash @@ -219,13 +221,13 @@ jobs: publish-nightly: name: publish-nightly + if: ${{ false }} runs-on: ubuntu-latest needs: - metadata - v8-linux - v8-macos - v8-wasix - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} env: GH_TOKEN: ${{ secrets.RELEASE_PLEASE_GH_TOKEN }} TARGET_REPO: wasmerio/edgejs-nightlies @@ -367,7 +369,12 @@ jobs: "${files[@]}" - name: Install Wasmer CLI - uses: wasmerio/setup-wasmer@v3 + shell: bash + run: | + set -euo pipefail + curl https://get.wasmer.io -sSfL | sh -s "v7.2.0-alpha.3" + echo "${HOME}/.wasmer/bin" >> "${GITHUB_PATH}" + "${HOME}/.wasmer/bin/wasmer" --version - name: Publish to wasmer.wtf env: diff --git a/.gitmodules b/.gitmodules index 8b27b9074..278861056 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,10 +1,6 @@ -[submodule "node"] - path = node - url = https://github.com/nodejs/node.git - branch = v24.x [submodule "test"] path = test - url = https://github.com/wasmerio/node-test.git + url = https://github.com/Arshia001/node-test.git [submodule "wasmer-examples"] path = wasmer-examples url = git@github.com:wasmerio/examples.git @@ -15,3 +11,11 @@ [submodule "ssl-certs"] path = ssl-certs url = https://github.com/wasix-org/ssl-certs.git +[submodule "deps/libuv-wasix"] + path = deps/libuv-wasix + url = https://github.com/wasix-org/libuv.git + branch = wasix-1.51.0 +[submodule "deps/openssl-wasix"] + path = deps/openssl-wasix + url = https://github.com/wasix-org/openssl.git + branch = wasix-3.5.8 diff --git a/Makefile b/Makefile index a54cd6758..f0948e1c7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build build-edge build-edge-quickjs-cli build-wasix build-quickjs-wasix build-napi build-napi-quickjs build-native-v8 build-native-quickjs build-wasix-napi build-wasix-napi-quickjs build-napi-wasmer-cli test-wasix-napi test-wasix-napi-quickjs test-wasix-napi-cli test-wasix-safe-mode test test-only check-portability clean clean-napi-quickjs clean-edge-quickjs-cli clean-dist dist dist-only framework-test framework-test-reset +.PHONY: build build-edge build-edge-quickjs-cli build-wasix build-quickjs-wasix build-napi build-napi-quickjs build-native-v8 build-native-quickjs build-wasix-napi build-wasix-napi-quickjs build-napi-wasmer-cli test-wasix-napi test-wasix-napi-quickjs test-wasix-napi-cli test-wasix-safe-mode test-wasix-quickjs-only test test-only check-portability clean clean-napi-quickjs clean-edge-quickjs-cli clean-dist dist dist-only framework-test framework-test-quickjs-native framework-test-quickjs-wasix framework-test-run framework-test-reset standalone-build-test standalone-build-test-run standalone-build-test-quickjs-native standalone-build-test-quickjs-wasix UNAME_S := $(shell uname -s) UNAME_M := $(shell uname -m) @@ -6,6 +6,7 @@ BUILD_DIR ?= build-edge BUILD_EDGE_QUICKJS_CLI_DIR ?= build-edge-quickjs-cli BUILD_WASIX_NAPI_DIR ?= build-wasix-napi BUILD_QUICKJS_WASIX_DIR ?= build-quickjs-wasix +QUICKJS_WASIX_WASM := $(BUILD_QUICKJS_WASIX_DIR)/edgejs.wasm DIST_DIR ?= dist DIST_BIN_DIR ?= $(DIST_DIR)/bin DIST_BIN_COMPAT_DIR ?= $(DIST_DIR)/bin-compat @@ -21,7 +22,11 @@ EXTRA_CMAKE_ARGS ?= NAPI_V8_PREBUILT_VERSION ?= 11.9.2 NAPI_V8_PLATFORM := FRAMEWORK_TEST_SCRIPT := $(CURDIR)/scripts/framework-test.js +STANDALONE_BUILD_TEST_SCRIPT := $(CURDIR)/scripts/standalone-build-test.js FRAMEWORK_TEST_SELECTOR := $(filter js-%,$(MAKECMDGOALS)) +FRAMEWORK_TEST_ORCHESTRATOR ?= node +WASIX_FRAMEWORK_RUNNER := $(CURDIR)/scripts/edge-wasix-framework-runner.sh +QUICKJS_EDGE_BINARY := $(BUILD_EDGE_QUICKJS_CLI_DIR)/edge NAPI_WASMER_DIR ?= napi NAPI_WASMER_CARGO_TARGET_DIR ?= $(abspath $(BUILD_WASIX_NAPI_DIR)/target) NAPI_WASMER_BINARY ?= $(NAPI_WASMER_CARGO_TARGET_DIR)/debug/napi_wasmer @@ -30,6 +35,7 @@ WASIX_NAPI_SMOKE_JS ?= console.log('hello world!'); WASMER_BIN ?= wasmer WASIX_PACKAGE_DIR ?= $(CURDIR) WASIX_SSL_CERTS_DIR ?= ssl-certs +WASIX_QUICKJS_NODE_TEST_RUNNER ?= $(CURDIR)/scripts/edge-wasix-node-runner.sh EDGE_VERSION_MAJOR := $(shell awk '$$2 == "EDGE_MAJOR_VERSION" {print $$3; exit}' src/edge_version.h) EDGE_VERSION_MINOR := $(shell awk '$$2 == "EDGE_MINOR_VERSION" {print $$3; exit}' src/edge_version.h) EDGE_VERSION_PATCH := $(shell awk '$$2 == "EDGE_PATCH_VERSION" {print $$3; exit}' src/edge_version.h) @@ -90,6 +96,109 @@ QUICKJS_SKIP_WORKER_TESTS := parallel/test-diagnostics-channel-worker-threads.js QUICKJS_SKIP_TLS_TESTS := parallel/test-tls-close-notify.js QUICKJS_SKIP_TESTS ?= $(EDGE_NODE_TEST_SKIP_TESTS),$(QUICKJS_SKIP_USING_PARSER_TESTS),$(QUICKJS_SKIP_WORKER_TESTS),$(QUICKJS_SKIP_TLS_TESTS) +# Expected WASIX environment limits from the 2026-06-23 triage run (1674 passed / +# 64 failed). These 52 tests are unix sockets, cluster/fork, subprocess/shell, +# homedir/priority, stack-overflow console, UDP gaps, unsupported crypto, and +# TLS env/keylog subprocess harnesses. The 12 in-process parity targets below +# are tracked in plans/quickjs-wasm/development/010_wasix_remaining_node_test_failures.md. +WASIX_SKIP_UNIX_SOCKET_TESTS := \ + parallel/test-http-client-abort-keep-alive-queued-unix-socket.js \ + parallel/test-http-client-abort-unix-socket.js \ + parallel/test-http-client-pipe-end.js \ + parallel/test-http-unix-socket-keep-alive.js \ + parallel/test-http-unix-socket.js \ + parallel/test-https-unix-socket-self-signed.js \ + parallel/test-http2-pipe-named-pipe.js \ + parallel/test-http2-respond-file-error-pipe-offset.js \ + parallel/test-tls-connect-pipe.js \ + parallel/test-tls-net-connect-prefer-path.js \ + parallel/test-tls-wrap-econnreset-pipe.js \ + parallel/test-http-client-response-domain.js +WASIX_SKIP_CLUSTER_FORK_TESTS := \ + parallel/test-dgram-bind-socket-close-before-cluster-reply.js \ + parallel/test-dgram-cluster-close-during-bind.js \ + parallel/test-dgram-cluster-close-in-listening.js \ + parallel/test-dgram-unref-in-cluster.js \ + parallel/test-http-server-drop-connections-in-cluster.js \ + parallel/test-tls-ticket-cluster.js \ + parallel/test-diagnostics-channel-process.js \ + parallel/test-http-chunk-problem.js \ + parallel/test-http-client-with-create-connection.js \ + parallel/test-http-full-response.js \ + parallel/test-http-server-stale-close.js \ + parallel/test-dgram-deprecation-error.js \ + parallel/test-https-agent-unref-socket.js \ + parallel/test-crypto-secure-heap.js \ + parallel/test-domain-top-level-error-handler-throw.js \ + parallel/test-domain-uncaught-exception.js \ + sequential/test-dgram-bind-shared-ports.js +WASIX_SKIP_SUBPROCESS_SHELL_TESTS := \ + parallel/test-stream-pipeline-process.js \ + parallel/test-domain-abort-on-uncaught.js \ + sequential/test-stream2-stderr-sync.js +WASIX_SKIP_OS_TESTS := \ + parallel/test-os-homedir-no-envvar.js \ + parallel/test-os.js \ + parallel/test-os-process-priority.js +WASIX_SKIP_STACK_OVERFLOW_TESTS := \ + parallel/test-console-log-throw-primitive.js \ + parallel/test-console-no-swallow-stack-overflow.js \ + parallel/test-console-sync-write-error.js \ + parallel/test-ttywrap-stack.js +WASIX_SKIP_UDP_TESTS := \ + parallel/test-dgram-createSocket-type.js \ + parallel/test-dgram-exclusive-implicit-bind.js \ + parallel/test-dgram-setTTL.js +WASIX_SKIP_CRYPTO_UNSUPPORTED_TESTS := \ + parallel/test-crypto-argon2.js \ + parallel/test-crypto-no-algorithm.js \ + parallel/test-webcrypto-derivebits-argon2.js \ + parallel/test-crypto-pqc-keygen-slh-dsa.js +WASIX_SKIP_TLS_SUBPROCESS_ENV_TESTS := \ + parallel/test-tls-enable-keylog-cli.js \ + parallel/test-tls-env-bad-extra-ca.js \ + parallel/test-tls-env-extra-ca-no-crypto.js \ + parallel/test-tls-env-extra-ca.js \ + parallel/test-tls-env-extra-ca-with-options.js +WASIX_SKIP_MISC_ENV_TESTS := \ + parallel/test-http2-tls-disconnect.js \ + parallel/test-http2-misbehaving-flow-control-paused.js +# Known in-process WASIX parity gaps (see 010_wasix_remaining_node_test_failures.md). +WASIX_SKIP_PARITY_TESTS := \ + client-proxy/test-http-proxy-request-connection-refused.mjs \ + client-proxy/test-https-proxy-request-connection-refused.mjs \ + sequential/test-http-econnrefused.js \ + sequential/test-tls-connect.js \ + parallel/test-dns-perf_hooks.js \ + parallel/test-dns-setserver-when-querying.js \ + parallel/test-http-writable-true-after-close.js \ + parallel/test-fastutf8stream-mode.js \ + parallel/test-tls-alert-handling.js \ + parallel/test-tls-error-stack.js \ + parallel/test-tls-hello-parser-failure.js \ + parallel/test-tls-junk-server.js +# CI-only harness timeouts under parallel WASIX load (default harness timeout is 10s). +WASIX_SLOW_TESTS := \ + parallel/test-buffer-constants.js \ + parallel/test-crypto-oneshot-hash-xof.js \ + parallel/test-fastutf8stream-flush-sync.js \ + parallel/test-http2-respond-file-with-pipe.js \ + parallel/test-stringbytes-external.js \ + parallel/test-url-parse-invalid-input.js \ + parallel/test-webcrypto-wrap-unwrap.js +WASIX_SLOW_TEST_TIMEOUT_SCALE ?= 12 +WASIX_SKIP_ENV_TESTS ?= $(subst $(SPACE),$(COMMA),$(strip \ + $(WASIX_SKIP_UNIX_SOCKET_TESTS) \ + $(WASIX_SKIP_CLUSTER_FORK_TESTS) \ + $(WASIX_SKIP_SUBPROCESS_SHELL_TESTS) \ + $(WASIX_SKIP_OS_TESTS) \ + $(WASIX_SKIP_STACK_OVERFLOW_TESTS) \ + $(WASIX_SKIP_UDP_TESTS) \ + $(WASIX_SKIP_CRYPTO_UNSUPPORTED_TESTS) \ + $(WASIX_SKIP_TLS_SUBPROCESS_ENV_TESTS) \ + $(WASIX_SKIP_MISC_ENV_TESTS) \ + $(WASIX_SKIP_PARITY_TESTS))) + ifeq ($(UNAME_S),Darwin) BUILD_ENV := env -u CPPFLAGS -u LDFLAGS endif @@ -156,6 +265,9 @@ build-wasix: build-quickjs-wasix: ./quickjs-wasm/build.sh +$(QUICKJS_WASIX_WASM): + ./quickjs-wasm/build.sh + build-wasix-napi: build-wasix build-napi-wasmer-cli build-wasix-napi-quickjs: build-quickjs-wasix @@ -191,6 +303,13 @@ test-quickjs-only: --skip-tests=$(QUICKJS_SKIP_TESTS) \ -j $(TEST_JOBS) +test-wasix-quickjs-only: + WASIX_SLOW_TESTS="$(subst $(SPACE),$(COMMA),$(strip $(WASIX_SLOW_TESTS)))" \ + WASIX_SLOW_TEST_TIMEOUT_SCALE="$(WASIX_SLOW_TEST_TIMEOUT_SCALE)" \ + NODE_TEST_RUNNER=$(WASIX_QUICKJS_NODE_TEST_RUNNER) WASMER_BIN="$(WASMER_BIN)" EDGEJS_ROOT="$(CURDIR)" WASIX_EDGEJS_PACKAGE_DIR="$(CURDIR)/quickjs-wasm" ./test/nodejs_test_harness --category=node:buffer,node:console,node:dgram,node:diagnostics_channel,node:dns,node:events,node:http,node:https,node:os,node:path,node:punycode,node:querystring,node:stream,node:string_decoder,node:tty,node:url,node:zlib,node:crypto,node:domain,node:http2,node:tls,node:sys \ + --skip-tests=$(QUICKJS_SKIP_TESTS),$(WASIX_SKIP_ENV_TESTS) \ + -j $(TEST_JOBS) + test-bytecode-cache: EDGE_BIN=$(EDGE_BINARY) ./scripts/test-bytecode-cache.sh @@ -268,9 +387,41 @@ dist-only: cd $(DIST_DIR) && zip -r ../$(ZIP_NAME) bin bin-compat README.md; \ fi +framework-test-run: + @command -v "$(FRAMEWORK_TEST_ORCHESTRATOR)" >/dev/null 2>&1 || { \ + echo "error: $(FRAMEWORK_TEST_ORCHESTRATOR) is required to run framework-test" >&2; \ + exit 1; \ + } + @SYMLINK_TARGET="$(SYMLINK_TARGET)" \ + EDGEJS_ROOT="$(CURDIR)" \ + FRAMEWORK_TEST_SKIP_SAFE="$(FRAMEWORK_TEST_SKIP_SAFE)" \ + FRAMEWORK_TEST_NODE_SKIP="$(FRAMEWORK_TEST_NODE_SKIP)" \ + FRAMEWORK_TEST_EDGE_SKIP="$(FRAMEWORK_TEST_EDGE_SKIP)" \ + FRAMEWORK_TEST_RUNNER_LABEL="$(FRAMEWORK_TEST_RUNNER_LABEL)" \ + "$(FRAMEWORK_TEST_ORCHESTRATOR)" "$(FRAMEWORK_TEST_SCRIPT)" test $(FRAMEWORK_TEST_SELECTOR) + framework-test: $(EDGE_BINARY) @"$(EDGE_BINARY)" "$(FRAMEWORK_TEST_SCRIPT)" test $(FRAMEWORK_TEST_SELECTOR) +framework-test-quickjs-native: $(QUICKJS_EDGE_BINARY) + @SYMLINK_TARGET="$(abspath $(QUICKJS_EDGE_BINARY))" \ + FRAMEWORK_TEST_SKIP_SAFE=1 \ + FRAMEWORK_TEST_RUNNER_LABEL='EdgeJS QuickJS Native' \ + $(MAKE) framework-test-run $(FRAMEWORK_TEST_SELECTOR) + +framework-test-quickjs-wasix: $(QUICKJS_WASIX_WASM) + @chmod +x "$(WASIX_FRAMEWORK_RUNNER)" + @command -v "$(WASMER_BIN)" >/dev/null 2>&1 || { \ + echo "error: $(WASMER_BIN) is required for framework-test-quickjs-wasix" >&2; \ + exit 1; \ + } + @SYMLINK_TARGET="$(abspath $(WASIX_FRAMEWORK_RUNNER))" \ + FRAMEWORK_TEST_SKIP_SAFE=1 \ + FRAMEWORK_TEST_NODE_SKIP='js-docusaurus-staticsite,js-docusaurus2-staticsite' \ + FRAMEWORK_TEST_EDGE_SKIP='js-astro-ssr-standalone,js-next-ssr' \ + FRAMEWORK_TEST_RUNNER_LABEL='EdgeJS QuickJS WASIX' \ + $(MAKE) framework-test-run $(FRAMEWORK_TEST_SELECTOR) + framework-test-reset: @if [ -x "$(EDGE_BINARY)" ]; then \ "$(EDGE_BINARY)" "$(FRAMEWORK_TEST_SCRIPT)" reset $(FRAMEWORK_TEST_SELECTOR); \ @@ -281,5 +432,36 @@ framework-test-reset: exit 1; \ fi +standalone-build-test-run: + @command -v "$(FRAMEWORK_TEST_ORCHESTRATOR)" >/dev/null 2>&1 || { \ + echo "error: $(FRAMEWORK_TEST_ORCHESTRATOR) is required to run standalone-build-test" >&2; \ + exit 1; \ + } + @SYMLINK_TARGET="$(SYMLINK_TARGET)" \ + EDGEJS_ROOT="$(CURDIR)" \ + FRAMEWORK_TEST_SKIP_SAFE="$(FRAMEWORK_TEST_SKIP_SAFE)" \ + FRAMEWORK_TEST_NODE_SKIP="$(FRAMEWORK_TEST_NODE_SKIP)" \ + FRAMEWORK_TEST_EDGE_SKIP="$(FRAMEWORK_TEST_EDGE_SKIP)" \ + FRAMEWORK_TEST_RUNNER_LABEL="$(FRAMEWORK_TEST_RUNNER_LABEL)" \ + "$(FRAMEWORK_TEST_ORCHESTRATOR)" "$(STANDALONE_BUILD_TEST_SCRIPT)" test $(FRAMEWORK_TEST_SELECTOR) + +standalone-build-test-quickjs-native: $(QUICKJS_EDGE_BINARY) + @SYMLINK_TARGET="$(abspath $(QUICKJS_EDGE_BINARY))" \ + FRAMEWORK_TEST_SKIP_SAFE=1 \ + FRAMEWORK_TEST_RUNNER_LABEL='EdgeJS QuickJS Native' \ + $(MAKE) standalone-build-test-run $(FRAMEWORK_TEST_SELECTOR) + +standalone-build-test-quickjs-wasix: $(QUICKJS_WASIX_WASM) + @chmod +x "$(WASIX_FRAMEWORK_RUNNER)" + @command -v "$(WASMER_BIN)" >/dev/null 2>&1 || { \ + echo "error: $(WASMER_BIN) is required for standalone-build-test-quickjs-wasix" >&2; \ + exit 1; \ + } + @SYMLINK_TARGET="$(abspath $(WASIX_FRAMEWORK_RUNNER))" \ + FRAMEWORK_TEST_SKIP_SAFE=1 \ + FRAMEWORK_TEST_EDGE_SKIP='js-astro-ssr-standalone,js-next-ssr' \ + FRAMEWORK_TEST_RUNNER_LABEL='EdgeJS QuickJS WASIX' \ + $(MAKE) standalone-build-test-run $(FRAMEWORK_TEST_SELECTOR) + js-%: @: diff --git a/cmake/EdgeOptions.cmake b/cmake/EdgeOptions.cmake index 5684e42d8..fd5a1e9eb 100644 --- a/cmake/EdgeOptions.cmake +++ b/cmake/EdgeOptions.cmake @@ -4,14 +4,6 @@ function(edge_configure_options) CACHE STRING "Default Wasmer package used by edge --safe" ) - set(NAPI_V8_NODE_ROOT_DEFAULT "${PROJECT_ROOT}/node") - if(DEFINED ENV{NAPI_V8_NODE_ROOT}) - set(NAPI_V8_NODE_ROOT_DEFAULT "$ENV{NAPI_V8_NODE_ROOT}") - endif() - set(NAPI_V8_NODE_ROOT - "${NAPI_V8_NODE_ROOT_DEFAULT}" - CACHE PATH "Path to Node source root (for raw Node tests/fixtures)" - ) option(EDGE_EXTERNAL_NAPI_V8 "Deprecated alias. Use EDGE_NAPI_PROVIDER=imports." OFF @@ -61,7 +53,6 @@ function(edge_configure_options) endif() set(EDGE_DEFAULT_WASMER_PACKAGE "${EDGE_DEFAULT_WASMER_PACKAGE}" PARENT_SCOPE) - set(NAPI_V8_NODE_ROOT "${NAPI_V8_NODE_ROOT}" PARENT_SCOPE) set(EDGE_EXTERNAL_NAPI_V8 "${EDGE_EXTERNAL_NAPI_V8}" PARENT_SCOPE) set(EDGE_ALLOW_UNDEFINED_IMPORTS "${EDGE_ALLOW_UNDEFINED_IMPORTS}" PARENT_SCOPE) set(EDGE_PREFER_REPO_LOCAL_V8 "${EDGE_PREFER_REPO_LOCAL_V8}" PARENT_SCOPE) diff --git a/deps/libuv-wasix b/deps/libuv-wasix new file mode 160000 index 000000000..cb7e09aed --- /dev/null +++ b/deps/libuv-wasix @@ -0,0 +1 @@ +Subproject commit cb7e09aed2fb784255d108d7c78c2063a61b3865 diff --git a/deps/openssl-wasix b/deps/openssl-wasix new file mode 160000 index 000000000..a8632cb81 --- /dev/null +++ b/deps/openssl-wasix @@ -0,0 +1 @@ +Subproject commit a8632cb81bc5a62f77f6286019ac922d1cd8e270 diff --git a/lib/internal/streams/fast-utf8-stream.js b/lib/internal/streams/fast-utf8-stream.js index 25f4771d0..68601cf5c 100644 --- a/lib/internal/streams/fast-utf8-stream.js +++ b/lib/internal/streams/fast-utf8-stream.js @@ -6,15 +6,12 @@ const { ArrayPrototypePush, - AtomicsWait, - Int32Array, MathMax, - Number, SymbolDispose, } = primordials; const { - constructSharedArrayBuffer, + sleep, } = require('internal/util'); const { @@ -50,22 +47,6 @@ const { const BUSY_WRITE_TIMEOUT = 100; const kEmptyBuffer = Buffer.allocUnsafe(0); -const kNil = new Int32Array(constructSharedArrayBuffer(4)); - -function sleep(ms) { - // Also filters out NaN, non-number types, including empty strings, but allows bigints - const valid = ms > 0 && ms < Infinity; - if (valid === false) { - if (typeof ms !== 'number' && typeof ms !== 'bigint') { - throw new ERR_INVALID_ARG_TYPE('ms', ['number', 'bigint'], ms); - } - throw new ERR_INVALID_ARG_VALUE.RangeError('ms', ms, - 'must be a number greater than 0 and less than Infinity'); - } - - AtomicsWait(kNil, 0, 0, Number(ms)); -} - // 16 KB. Don't write more than docker buffer size. // https://github.com/moby/moby/blob/513ec73831269947d38a644c278ce3cac36783b2/daemon/logger/copier.go#L13 const kMaxWrite = 16 * 1024; @@ -237,7 +218,7 @@ class Utf8Stream extends EventEmitter { this.on('newListener', (name) => { if (name === 'drain') { - this._asyncDrainScheduled = false; + this.#asyncDrainScheduled = false; } }); @@ -894,11 +875,23 @@ class Utf8Stream extends EventEmitter { * @returns {{writingBuf: string | Buffer, len: number}} released writingBuf and length */ function releaseWritingBuf(writingBuf, len, n) { - // if Buffer.byteLength is equal to n, that means writingBuf contains no multi-byte character - if (typeof writingBuf === 'string' && Buffer.byteLength(writingBuf) !== n) { - // Since the fs.write callback parameter `n` means how many bytes the passed of string - // We calculate the original string length for avoiding the multi-byte character issue - n = Buffer.from(writingBuf).subarray(0, n).toString().length; + if (typeof writingBuf === 'string') { + const byteLength = Buffer.byteLength(writingBuf); + if (byteLength !== n) { + // Since fs.write returns the number of bytes written, we need to find + // how many complete characters fit within those n bytes. + // If a partial write splits a multi-byte UTF-8 character, we must back up + // to the start of that character to avoid data corruption. + const buf = Buffer.from(writingBuf); + // Back up from position n to find a valid UTF-8 character boundary. + // UTF-8 continuation bytes have the pattern 10xxxxxx (0x80-0xBF). + // We need to find the start of the character that was split. + while (n > 0 && (buf[n] & 0xC0) === 0x80) { + n--; + } + // Decode the properly-aligned bytes to get the character count. + n = buf.subarray(0, n).toString().length; + } } len = MathMax(len - n, 0); writingBuf = writingBuf.slice(n); diff --git a/napi b/napi index a28fe12c8..bfe2ddcc8 160000 --- a/napi +++ b/napi @@ -1 +1 @@ -Subproject commit a28fe12c8d719e53120af138d0c166ac599d4fc7 +Subproject commit bfe2ddcc80d4fca36876204184e9468bf1d74c91 diff --git a/node b/node deleted file mode 160000 index 71fb7c696..000000000 --- a/node +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 71fb7c69675ebda88387ada0a77a0c697d257623 diff --git a/plans/framework-integration-tests.md b/plans/framework-integration-tests.md index a852f1192..21d324bcb 100644 --- a/plans/framework-integration-tests.md +++ b/plans/framework-integration-tests.md @@ -37,6 +37,14 @@ The supported operator entrypoints are: - `make framework-test` - `make framework-test ` +- `make framework-test-quickjs-native` +- `make framework-test-quickjs-native ` +- `make framework-test-quickjs-wasix` +- `make framework-test-quickjs-wasix ` +- `make standalone-build-test-quickjs-native` +- `make standalone-build-test-quickjs-native ` +- `make standalone-build-test-quickjs-wasix` +- `make standalone-build-test-quickjs-wasix ` - `make framework-test-reset` - `make framework-test-reset ` @@ -51,11 +59,46 @@ The helper script also supports direct invocation: - `SYMLINK_TARGET=` - selects the comparison runner for the non-Node stages - defaults to `build-edge/edge` +- `FRAMEWORK_TEST_RUNNER_LABEL=