Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(driver-adapters): enable Wasm on driver-adapters, with further deduplications required later #4456

Closed
wants to merge 82 commits into from

Conversation

jkomyno
Copy link
Contributor

@jkomyno jkomyno commented Nov 15, 2023

This PR contributes to https://github.com/prisma/team-orm/issues/548, and depends on #4455.

Idea: add Wasm support to driver-adapters, which currently relies on napi.rs only, by splitting the wasm-specific logic into the wasm module, and the napi.rs-specific logic into the napi module.

These modules are mutually exclusive and provide almost the same public API.
The wasm module is compiled when the target architecture is wasm32-*, and napi is used otherwise.

See Slack thread for context about it.


For what is worth, I think this PR is good enough for getting the vertical slice asap, but not for integrating into main, as I pointed our in a few comments.

jkomyno and others added 30 commits November 10, 2023 13:49
…github.com:prisma/prisma-engines into feat/sql-query-connector-on-wasm32-unknown-unknown
@jkomyno jkomyno marked this pull request as ready for review November 17, 2023 21:25
@jkomyno jkomyno requested a review from a team as a code owner November 17, 2023 21:25
@jkomyno jkomyno requested review from miguelff and Druue and removed request for a team November 17, 2023 21:25
@jkomyno jkomyno added this to the 5.7.0 milestone Nov 17, 2023
@jkomyno jkomyno removed their assignment Nov 20, 2023
Comment on lines 27 to 41

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
napi.workspace = true
napi-derive.workspace = true
quaint.workspace = true

[target.'cfg(target_arch = "wasm32")'.dependencies]
quaint = { path = "../../quaint" }
js-sys.workspace = true
serde-wasm-bindgen.workspace = true
wasm-bindgen.workspace = true
wasm-bindgen-futures.workspace = true
tsify.workspace = true
ducktor = "0.1.0"
pin-project = "1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you should be able to use quaint's workspace version in both cases here. See doc here

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I didn't know this about resolver = "2".

wasm-bindgen.workspace = true
wasm-bindgen-futures.workspace = true
tsify.workspace = true
ducktor = "0.1.0"
Copy link
Contributor

@Weakky Weakky Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency, ducktor, looks scary tbh. Looks unknown, a few months old with barely any tests. How much work does it remove from our plate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ducktor was one of the shortcuts taken (I already had some code using it laying around).

Removed in d6d09d6.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this change broke something:

Error: `unwrap_throw` failed
    at __wbindgen_throw (file:///Users/jkomyno/work/prisma/prisma-engines/query-engine/query-engine-wasm/pkg/query_engine_bg.js:977:11)
    at wasm://wasm/01063c0e:wasm-function[5374]:0x352371
    at wasm://wasm/01063c0e:wasm-function[3153]:0x32513b
    at wasm://wasm/01063c0e:wasm-function[93]:0x3902b

I'll take another look tomorrow.

@@ -125,10 +126,12 @@ impl QueryEngine {

let mut schema = psl::validate(datamodel.into());
let config = &mut schema.configuration;
let preview_features = config.preview_features();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks unused?

Copy link
Contributor

@Weakky Weakky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too much code duplication between driver-adapters:napi and driver-adapters::wasm. Some work needs to be done to have a shared implementation.

Base automatically changed from feat/request-handlers-on-wasm32-unknown-unknown to main November 21, 2023 11:12
@jkomyno
Copy link
Contributor Author

jkomyno commented Nov 22, 2023

This is currently broken, see #4456 (comment).

@jkomyno
Copy link
Contributor Author

jkomyno commented Nov 22, 2023

As per Slack, I'll be merging this to the vertical slice PR, #4466.

@jkomyno jkomyno changed the title feat(driver-adapters): enable Wasm on driver-adapters feat(driver-adapters): enable Wasm on driver-adapters, with further deduplications required later Nov 22, 2023
@jkomyno jkomyno closed this Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants