-
Notifications
You must be signed in to change notification settings - Fork 2.2k
web-thread backport to testnet_conway
#4985
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
Merged
Twey
merged 5 commits into
linera-io:testnet_conway
from
Twey:testnet/conway/web-thread
Nov 19, 2025
Merged
web-thread backport to testnet_conway
#4985
Twey
merged 5 commits into
linera-io:testnet_conway
from
Twey:testnet/conway/web-thread
Nov 19, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Motivation We are unhappy with the directory structure of `linera-web`, which looks too much like an SDK crate. ## Proposal Rename it to plain old `web` to indicate that it's not (published as) a crate, with the npm package structure (`@linera/client` and `@linera/signer`) reproduced inside. ## Test Plan CI. ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
## Motivation In linera-io#4577 I moved the npm packages around, but I forgot to update the pnpm workspace file. ## Proposal Update it with the new package paths. ## Test Plan Tested locally. ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
It's currently difficult to test the `@linera/client` package in isolation because it always requires a `Signer` instance to use, the most straightforward one of which is the `PrivateKey` signer that lives in `@linera/signer`. Integrate the private-key signer into the `@linera/client` package next to the `Signer` interface itself as `linera.PrivateKeySigner`. While we're breaking the API, fix up the package structure of `@linera/client` a bit (giving us a barrel file as a cleaner place to inject TypeScript code to live next to the Wasm and its generated shim), and remove some vestigial functions (`Signer.get_public_key()`, which is never used any more, and `Client.frontend()`, which made more sense when this library was intended to be the direct implementation of a Web extension). Since the erstwhile `@linera/signer` package now only contains the MetaMask signer, rename it to `@linera/metamask` and open up its scope to other MetaMask-specific signers and integrations. Automated tests forthcoming :) but I've at least tried it manually with our counter and native-fungible examples. - Nothing to do / These changes follow the usual release cycle. Breaks SDK API but no need to backport. - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
Contributor
Author
|
CI was not running on #4984, so hopefully this one will fare better. |
Currently all our testing for the Web client is manual. We'd like to know when PRs break our example apps. This PR sets up conventions for our Web tests that enable us to test in a variety of different environments. Going forward we can add more and more in-depth tests to cover more scenarios, and if we backport this PR we can also use these tests as an automated healthcheck for the deployed Web apps. We unify the Web tests using [Vitest](https://vitest.dev/) with a [Playwright](https://playwright.dev/) backend to run tests in real browsers (currently just Chromium, but we should also test at least on WebKit and Firefox once linera-io#4235 is fixed). Add a couple of basic tests for `@linera/client`: getting a wallet from the faucet and initializing the client. This is the test plan :) - These changes should be backported to the latest `testnet` branch, then - be released in a new SDK. - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
Our hacked-up version of `wasm_thread` isn't a great fit for our use cases. Firstly, `wasm_thread` aims to mimic the API of `std::thread`. This was never sufficient for us as we need to send non-`Send` messages across threads actively using `postMessage`, which `std::thread` has no equivalent for. We patched `wasm_thread` but it was at odds with the point of the package. Then, in order to use `wasm_thread` without threading a shim script URL through the code down into `linera-base`, we dynamically got the URL of the `wasm-bindgen` shim script using `import.meta.url`. This is poorly (and inconsistently) supported by bundlers, which want to know what the URL will be used for; but since the `Worker` construction in `wasm_thread` is done in Rust code they cannot analyze it. This resulted in our `@linera/client` library being rather fragile under different bundlers, with workarounds required to ensure they don't interfere with the paths of the various files. Introduce the [`web-thread`](https://docs.rs/web-thread/latest/web_thread/) library, a simplified equivalent to `wasm_thread` that has a Web-first API, including a trait for types that can be passed by `postMessage` (including [transferable objects](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Transferable_objects)), and whose worker logic is primarily implemented in JavaScript, making it much more comprehensible to bundlers. This allows us: - to communicate both `Send` and `Post` objects with long-running threads, as is required by linera-io#3651 and eventually linera-io#2927 - to remove the bundling caveats from Linera documentation - to support WebPack - to delete `linera_base::task` and the conditional compilation therein The `web-thread` library itself has been tested with Vite as well as WebPack (via Next.js with the `--webpack` flag), and includes example applications to that effect. I have manually tested our two Web applications in this repository. I defer to CI for full tests of the native pathways. - Nothing to do / These changes follow the usual release cycle. - Fixes linera-io#2809. - First step towards linera-io#3651. - [`web-thread` docs](https://docs.rs/web-thread/latest/web_thread/) Turbopack is currently not supported due to an open issue when processing cyclic dependencies. See the following discussions for more information: * vercel/next.js#85119 * vercel/next.js#77102 * emscripten-core/emscripten#20580
25f5a75 to
f11469a
Compare
Contributor
This happens when you change the base branch. The solution is to modify a commit and push again. |
Contributor
Author
|
Good to know for next time. Though it seems like a bit of an oversight! |
ma2bd
approved these changes
Nov 19, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
We'd like to be able to backport the OOM fix to
testnet_conway.Proposal
Get
testnet_conwayup-to-date with respect towebchanges onmain, up to and including:linera-webdirectory #4577)web: fixpnpm-workspace.yaml#4589)@linera/client: integrate signer #4711)wasm_threadwithweb-thread#4959)Test Plan
CI. Includes a PR that introduces (some) testing for the Web. Hopefully I didn't miss anything.
Release Plan
Links