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

[bug][wasm] defi framework support beyond web_sys::window context #1948

Open
ca333 opened this issue Aug 25, 2023 · 3 comments
Open

[bug][wasm] defi framework support beyond web_sys::window context #1948

ca333 opened this issue Aug 25, 2023 · 3 comments
Assignees
Labels
bug Something isn't working P1

Comments

@ca333
Copy link

ca333 commented Aug 25, 2023

test-environment:
Chrome 116.0.5845.96 (Official Build) (x86_64) and 116.0.5845.110 (Official Build) (arm64)

issue:
https://github.com/KomodoPlatform/komodo-defi-framework/blob/main/mm2src/mm2_db/src/indexed_db/drivers/builder.rs#L76 and https://github.com/KomodoPlatform/komodo-defi-framework/blob/main/mm2src/mm2_net/src/wasm_http.rs#L148 assume we are executing within a browser window context. However, the code can also be executed in a "background" context, such as a (service) worker or potentially other wasm runtimes ("server-side wasm"). Thus if triggered from such a background context, we face the following panics:

common:474] panicked at '!window', mm2s rc/mm2 db/src/indexed db/drivers/builder. rs: 76: 40 and
common: 474] panicked at '!window', mm2src/mm2 net/src/wasm http. rs: 148:40

on a side-note: faced/facing a similar issue with wasm-timer in our deps tree, which will be resolved with #1878 (thanks @ozkanonur - confirmed/tested with https://github.com/KomodoPlatform/komodo-defi-framework/tree/ca_dev) and by removing the wasm-timer dependency - was/is a similar issue (lack of worker context support) - err: common: 474] panicked at 'not in a browser', Lgithub/home/cargo/registry/src/github.com-1ecc6299db9ec823/wasm-timer-0.2.5/src/wasm.rs:58:19.


p.s. pushed a "experimental fix-attempt" in ae4a809 / f7b7f15 into https://github.com/KomodoPlatform/komodo-defi-framework/commits/ca_dev_wasm (for inspiration)

@ca333 ca333 added bug Something isn't working P1 labels Aug 25, 2023
@onur-ozkan
Copy link
Member

Thank you for the comprehensive report and the ref work. If there isn't anyone available in the team to take on this task at the moment, I can allocate time to work on it the week after next week.

cc @KomodoPlatform/mm2

@onur-ozkan
Copy link
Member

In addition, this makes me think why we don't have E2E tests for gui platforms including WASM with +80% coverage.

@onur-ozkan
Copy link
Member

In addition, this makes me think why we don't have E2E tests for gui platforms including WASM with +80% coverage.

These tests could be seamlessly integrated into cross-test pipelines with frameworks such as https://zuul-ci.org. By this approach, we could ensure that pull requests causing problems to our official mm2 clients, which are challenging to identify through manual means, are never merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1
Projects
None yet
Development

No branches or pull requests

2 participants