Skip to content

Commit

Permalink
qe-wasm: Partially fix tests (#4517)
Browse files Browse the repository at this point in the history
* qe-wasm: Partially fix the test suite

1. Bash script for build did not abort on error, hence sed error on
   linux went unnoticed.
2. We don't actually need sed trickery sincce `wasm-pack` has a flag for
   changing binary name.
3. `tracing` feature does not actually work on WASM even partially: it panics on
   `Instant` invokation as soon as first span is created. Since we are
   running tests with all preview features enabled, that means that
   practically any test panics now. Disabled it again.

A lot of tests are still failing on ThreadRng invocation and stacktrace
is not really helpful, but I still think it's better if we get it
working.

* Update query-engine/query-engine-wasm/build.sh
  • Loading branch information
SevInf authored Dec 6, 2023
1 parent 3ba08e2 commit c7c8586
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
21 changes: 4 additions & 17 deletions query-engine/query-engine-wasm/build.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
#!/bin/bash

set -e

# Call this script as `./build.sh <npm_version>`
set -euo pipefail

OUT_VERSION="$1"
OUT_VERSION="${1:-}"
OUT_FOLDER="pkg"
OUT_JSON="${OUT_FOLDER}/package.json"
OUT_TARGET="bundler"
OUT_NPM_NAME="@prisma/query-engine-wasm"

# The local ./Cargo.toml file uses "name = "query_engine_wasm" as library name
# to avoid conflicts with libquery's `name = "query_engine"` library name declaration.
# This little `sed -i` trick below is a hack to publish "@prisma/query-engine-wasm"
# with the same binding filenames currently expected by the Prisma Client.
sed -i.bak 's/name = "query_engine_wasm"/name = "query_engine"/g' Cargo.toml

# use `wasm-pack build --release` on CI only
if [[ -z "$BUILDKITE" ]] && [[ -z "$GITHUB_ACTIONS" ]]; then
if [[ -z "${BUILDKITE:-}" ]] && [[ -z "${GITHUB_ACTIONS:-}" ]]; then
BUILD_PROFILE="--dev"
else
BUILD_PROFILE="--release"
Expand All @@ -31,14 +25,7 @@ then
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
fi

wasm-pack build $BUILD_PROFILE --target $OUT_TARGET

sed -i.bak 's/name = "query_engine"/name = "query_engine_wasm"/g' Cargo.toml

# Remove the backup file created by sed. We only created it because there's no
# cross-platform way to specify we don't need one (it's just `-i` in GNU sed
# but `-i ""` in BSD sed).
rm Cargo.toml.bak
wasm-pack build $BUILD_PROFILE --target $OUT_TARGET --out-name query_engine

sleep 1

Expand Down
4 changes: 2 additions & 2 deletions query-engine/query-engine-wasm/example/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ datasource db {
}

generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
provider = "prisma-client-js"
previewFeatures = ["driverAdapters", "tracing"]
}

model User {
Expand Down
4 changes: 2 additions & 2 deletions query-engine/query-engine-wasm/src/wasm/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::{
};
use driver_adapters::JsObject;
use js_sys::Function as JsFunction;
use psl::PreviewFeature;
use query_core::{
protocol::EngineProtocol,
schema::{self, QuerySchema},
Expand Down Expand Up @@ -180,7 +179,8 @@ impl QueryEngine {
.validate_that_one_datasource_is_provided()
.map_err(|errors| ApiError::conversion(errors, schema.db.source()))?;

let enable_tracing = config.preview_features().contains(PreviewFeature::Tracing);
// Telemetry panics on timings if preview feature is enabled
let enable_tracing = false; // config.preview_features().contains(PreviewFeature::Tracing);
let engine_protocol = engine_protocol.unwrap_or(EngineProtocol::Json);

let builder = EngineBuilder {
Expand Down

0 comments on commit c7c8586

Please sign in to comment.